5

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.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
ecmanaut
  • 5,030
  • 2
  • 44
  • 66
  • If you have any feedback on the Input Events specifications, you might wish to [post a new Input Events GitHub issue](https://github.com/w3c/input-events/issues/new). I posted [issue #78](https://github.com/w3c/input-events/issues/78) with a similar question to this one, asking for more developer guidance for choosing between Levels 1 and 2. Hopefully there will be closer consensus between the browser vendors in the future; it seems to still be blocked by lower-level work, e.g., on `Range`s. – jschoi Nov 21 '18 at 03:23

1 Answers1

3

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'));

ecmanaut
  • 5,030
  • 2
  • 44
  • 66