W3cubDocs

/DOM

KeyboardEvent.constructor

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

Browser compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Basic support Yes ? 31 No Yes ?
Added code and key to KeyboardEventInit 49 ? ? ? ? ?
Mobile
Android webview Chrome for Android Edge Mobile Firefox for Android Opera for Android iOS Safari Samsung Internet
Basic support Yes Yes ? 31 Yes ? ?
Added code and key to KeyboardEventInit 49 49 ? ? ? ? ?

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent