Web/API/KeyboardEvent/KeyboardEvent

From Get docs

The KeyboardEvent() constructor creates a new KeyboardEvent.

Syntax

 event = new KeyboardEvent(typeArg, KeyboardEventInit);

Values

typeArg

Is a DOMString representing the name of the event.

KeyboardEventInitOptional

Is a KeyboardEventInit dictionary, having the following fields:

The KeyboardEventInit dictionary also accepts fields from the UIEventInit and EventInit dictionaries.


Specifications

Specification Status Comment
UI EventsThe definition of 'KeyboardEvent()' in that specification. Working Draft Current definition.
Document Object Model (DOM) Level 3 Events SpecificationThe definition of 'KeyboardEvent()' in that specification. Obsolete Initial definition.

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
KeyboardEvent() constructor Chrome

Full support Yes

Edge

Full support ≤79

Firefox

Full support 31

IE

No support No

Opera

Full support Yes

Safari

?

WebView Android

Full support Yes

Chrome Android

Full support Yes

Firefox Android

Full support 31

Opera Android

Full support Yes

Safari iOS

?

Samsung Internet Android

Full support Yes

Added code and key to KeyboardEventInit Chrome

Full support 49

Edge

Full support ≤79

Firefox

?

IE

No support No

Opera

?

Safari

?

WebView Android

Full support 49

Chrome Android

Full support 49

Firefox Android

?

Opera Android

?

Safari iOS

?

Samsung Internet Android

Full support 5.0

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown


See also