ecmanaut
ecmanaut

Reputation: 5150

How to feature detect Input Events Level 1 or 2 support?

Browser input events have been around long enough to be categorised into at least three different levels of support beside "no support", by now (recent history about the W3C specs on github):

How do you detect support for beforeinput events? At present time of writing (April 2018), Firefox is at 0, Chrome and Safari further along.

Upvotes: 5

Views: 720

Answers (1)

ecmanaut
ecmanaut

Reputation: 5150

My best hack, for the time being, is to construct a synthetic InputEvent and test if it has the inputType property, and use that as a proxy for "probably supports at least Level 1 of the W3C spec, and, by inference, the beforeinput event too":

const input_events_level_1_or_better = 'inputType' in (new InputEvent('input'));

Upvotes: 3

Related Questions