Reputation: 5150
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):
inputType
, nor beforeinput
, support)beforeinput
event, and the inputType
property, among other things)inputType
s - deleteByComposition
, insertCompositionText
, insertFromComposition
)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
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