dom / latest / keyboardevent / keyboardevent.html /

KeyboardEvent()

The KeyboardEvent() constructor creates a new KeyboardEvent.

Syntax

new KeyboardEvent(typeArg, KeyboardEventInit);

Values

typeArg

Is a DOMString representing the name of the event.

KeyboardEventInit Optional

Is a KeyboardEventInit dictionary, having the following fields:

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

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
KeyboardEvent
26
12
31
No
15
7
4.4
26
31
14
7
1.5

See also

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/KeyboardEvent