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

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) 31 (31) No support (Yes) ?
Add code and key to init 49.0        
Feature Android Android Webview Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support ? (Yes) 31.0 (31) No support (Yes) ? (Yes)
Add code and key to init No support 49.0         49.0

See also

Document Tags and Contributors

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