KeyboardEvent
Module: JavaScript DOM API
#include <KeyboardEvent.idl>
Public Functions
Section titled “Public Functions”| Name | |
|---|---|
| KeyboardEvent | KeyboardEvent(DOMInternedString type, optional KeyboardEventInit eventInitDict) |
| void | initKeyboardEvent(optional DOMInternedString typeArg, optional boolean bubblesArg, optional boolean cancelableArg, optional Window? viewArg, optional DOMString keyIdentifier, optional unsigned long locationArg, optional boolean ctrlKey, optional boolean altKey, optional boolean shiftKey, optional boolean metaKey, optional boolean altGraphKey) |
| boolean | getModifierState(DOMString keyIdentifier) Queries the state of a modifier using a key value. |
Public Attributes
Section titled “Public Attributes”| Name | |
|---|---|
| const unsigned long | DOM_KEY_LOCATION_STANDARD |
| const unsigned long | DOM_KEY_LOCATION_LEFT |
| const unsigned long | DOM_KEY_LOCATION_RIGHT |
| const unsigned long | DOM_KEY_LOCATION_NUMPAD |
| readonly attribute unsigned long | charCode keyCode is deprecated in HTML but a lot of existing code prefers it and it also is the standard thing to use in GT |
| readonly attribute unsigned long | keyCode |
| readonly attribute unsigned long | which |
| readonly attribute DOMString | key |
| readonly attribute DOMString | code |
| readonly attribute unsigned long | location Returns a Number representing the location of the key on the keyboard or other input device. |
| readonly attribute boolean | repeat Returns a boolean representing if the event is repeating (the user is holding the key down). |
| readonly attribute boolean | ctrlKey |
| readonly attribute boolean | shiftKey |
| readonly attribute boolean | altKey |
| readonly attribute boolean | metaKey |
Additional inherited members
Section titled “Additional inherited members”Public Functions inherited from UIEvent
| Name | |
|---|---|
| UIEvent | UIEvent(DOMInternedString type, optional UIEventInit initEvent) |
| void | initUIEvent(optional DOMInternedString type, optional boolean canBubble, optional boolean cancelable, optional Window? view, optional long detail) |
Public Attributes inherited from UIEvent
| Name | |
|---|---|
| readonly attribute long | detail |
Public Functions inherited from Event
| Name | |
|---|---|
| Event | Event(DOMInternedString type, optional EventInit initEvent) |
| void | stopPropagation() |
| void | preventDefault() |
| void | initEvent(optional DOMInternedString eventTypeArg, optional boolean canBubbleArg, optional boolean cancelableArg) |
| void | stopImmediatePropagation() |
Public Attributes inherited from Event
| Name | |
|---|---|
| const unsigned short | NONE |
| const unsigned short | CAPTURING_PHASE |
| const unsigned short | AT_TARGET |
| const unsigned short | BUBBLING_PHASE |
| readonly attribute DOMString | type |
| readonly attribute EventTarget | target |
| readonly attribute EventTarget | currentTarget |
| readonly attribute unsigned short | eventPhase |
| readonly attribute boolean | bubbles |
| readonly attribute boolean | cancelable |
| readonly attribute boolean | defaultPrevented |
| readonly attribute boolean | composed |
Public Functions Documentation
Section titled “Public Functions Documentation”function KeyboardEvent
Section titled “function KeyboardEvent”KeyboardEvent KeyboardEvent( DOMInternedString type, optional KeyboardEventInit eventInitDict)function initKeyboardEvent
Section titled “function initKeyboardEvent”void initKeyboardEvent( optional DOMInternedString typeArg, optional boolean bubblesArg, optional boolean cancelableArg, optional Window? viewArg, optional DOMString keyIdentifier, optional unsigned long locationArg, optional boolean ctrlKey, optional boolean altKey, optional boolean shiftKey, optional boolean metaKey, optional boolean altGraphKey)function getModifierState
Section titled “function getModifierState”boolean getModifierState( DOMString keyIdentifier)Queries the state of a modifier using a key value.
Parameters:
- keyIdentifier A modifier key value.
Return: true if it is a modifier key and the modifier is activated, false otherwise.
Public Attributes Documentation
Section titled “Public Attributes Documentation”variable DOM_KEY_LOCATION_STANDARD
Section titled “variable DOM_KEY_LOCATION_STANDARD”const unsigned long DOM_KEY_LOCATION_STANDARD = 0x00;variable DOM_KEY_LOCATION_LEFT
Section titled “variable DOM_KEY_LOCATION_LEFT”const unsigned long DOM_KEY_LOCATION_LEFT = 0x01;variable DOM_KEY_LOCATION_RIGHT
Section titled “variable DOM_KEY_LOCATION_RIGHT”const unsigned long DOM_KEY_LOCATION_RIGHT = 0x02;variable DOM_KEY_LOCATION_NUMPAD
Section titled “variable DOM_KEY_LOCATION_NUMPAD”const unsigned long DOM_KEY_LOCATION_NUMPAD = 0x03;variable charCode
Section titled “variable charCode”readonly attribute unsigned long charCode;keyCode is deprecated in HTML but a lot of existing code prefers it and it also is the standard thing to use in GT
variable keyCode
Section titled “variable keyCode”readonly attribute unsigned long keyCode;variable which
Section titled “variable which”readonly attribute unsigned long which;variable key
Section titled “variable key”readonly attribute DOMString key;variable code
Section titled “variable code”readonly attribute DOMString code;variable location
Section titled “variable location”readonly attribute unsigned long location;Returns a Number representing the location of the key on the keyboard or other input device.
variable repeat
Section titled “variable repeat”readonly attribute boolean repeat;Returns a boolean representing if the event is repeating (the user is holding the key down).
variable ctrlKey
Section titled “variable ctrlKey”readonly attribute boolean ctrlKey;variable shiftKey
Section titled “variable shiftKey”readonly attribute boolean shiftKey;variable altKey
Section titled “variable altKey”readonly attribute boolean altKey;variable metaKey
Section titled “variable metaKey”readonly attribute boolean metaKey;© 2026 Coherent Labs. All rights reserved.