KeyboardEvent()

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 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

BCD tables only load in the browser

See also