The KeyboardEvent() constructor creates a new KeyboardEvent object.
new KeyboardEvent(type)
new KeyboardEvent(type, options)typeA string with the name of the event. It is case-sensitive and browsers set it to keydown, keyup, or keypress.
options OptionalAn object that, in addition of the properties defined in UIEvent(), can have the following properties:
key OptionalA string, defaulting to "", that sets the value of KeyboardEvent.key.
code OptionalA string, defaulting to "", that sets the value of KeyboardEvent.code.
location OptionalA number, defaulting to 0, that sets the value of KeyboardEvent.location.
repeat OptionalA boolean value, defaulting to false, that sets the value of KeyboardEvent.repeat.
isComposing OptionalA boolean value, defaulting to false, that sets the value of KeyboardEvent.isComposing.
charCode Optional A number, defaulting to 0, that sets the value of the deprecated KeyboardEvent.charCode.
keyCode Optional A number, defaulting to 0, that sets the value of the deprecated KeyboardEvent.keyCode.
which Optional A number, defaulting to 0, that sets the value of the deprecated UIEvent.which.
ctrlKey OptionalA boolean value, defaulting to false, that sets the value of KeyboardEvent.ctrlKey.
shiftKey OptionalA boolean value, defaulting to false, that sets the value of KeyboardEvent.shiftKey.
altKey OptionalA boolean value, defaulting to false, that sets the value of KeyboardEvent.altKey.
metaKey OptionalA boolean value, defaulting to false, that sets the value of KeyboardEvent.metaKey.
A new KeyboardEvent object.
KeyboardEvent, the interface of the objects it constructs.