The KeyboardEvent() constructor creates a new KeyboardEvent.


 event = new KeyboardEvent(typeArg, KeyboardEventInit);


Is a DOMString representing the name of the event.
Is a KeyboardEventInit dictionary, having the following fields:

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


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

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support Yes ?31 No Yes ?
Added code and key to KeyboardEventInit49 ? ? ? ? ?
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support Yes Yes ?31 Yes ? ?
Added code and key to KeyboardEventInit4949 ? ? ? ? ?

See also

Document Tags and Contributors

Contributors to this page: fscholz, jpmedley, jwhitlock, torbasow, nyrosmith, teoli
Last updated by: fscholz,