KeyboardEvent

Module: JavaScript DOM API

#include <KeyboardEvent.idl>

Inherits from UIEvent, Event

Public Functions

Name
KeyboardEventKeyboardEvent(DOMInternedString type, optional KeyboardEventInit eventInitDict)
voidinitKeyboardEvent(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)
booleangetModifierState(DOMString keyIdentifier)
Queries the state of a modifier using a key value.

Public Attributes

Name
const unsigned longDOM_KEY_LOCATION_STANDARD
const unsigned longDOM_KEY_LOCATION_LEFT
const unsigned longDOM_KEY_LOCATION_RIGHT
const unsigned longDOM_KEY_LOCATION_NUMPAD
readonly attribute unsigned longcharCode
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 longkeyCode
readonly attribute unsigned longwhich
readonly attribute DOMStringkey
readonly attribute DOMStringcode
readonly attribute unsigned longlocation
Returns a Number representing the location of the key on the keyboard or other input device.
readonly attribute booleanrepeat
Returns a boolean representing if the event is repeating (the user is holding the key down).
readonly attribute booleanctrlKey
readonly attribute booleanshiftKey
readonly attribute booleanaltKey
readonly attribute booleanmetaKey

Additional inherited members

Public Functions inherited from UIEvent

Name
UIEventUIEvent(DOMInternedString type, optional UIEventInit initEvent)
voidinitUIEvent(optional DOMInternedString type, optional boolean canBubble, optional boolean cancelable, optional Window? view, optional long detail)

Public Functions inherited from Event

Name
EventEvent(DOMInternedString type, optional EventInit initEvent)
voidstopPropagation()
voidpreventDefault()
voidinitEvent(optional DOMInternedString eventTypeArg, optional boolean canBubbleArg, optional boolean cancelableArg)
voidstopImmediatePropagation()

Public Attributes inherited from Event

Name
const unsigned shortNONE
const unsigned shortCAPTURING_PHASE
const unsigned shortAT_TARGET
const unsigned shortBUBBLING_PHASE
readonly attribute DOMStringtype
readonly attribute EventTargettarget
readonly attribute EventTargetcurrentTarget
readonly attribute unsigned shorteventPhase
readonly attribute booleanbubbles
readonly attribute booleancancelable
readonly attribute booleandefaultPrevented

Public Functions Documentation

function KeyboardEvent

KeyboardEvent KeyboardEvent(
    DOMInternedString type,
    optional KeyboardEventInit eventInitDict
)

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

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

variable DOM_KEY_LOCATION_STANDARD

const unsigned long DOM_KEY_LOCATION_STANDARD = 0x00;

variable DOM_KEY_LOCATION_LEFT

const unsigned long DOM_KEY_LOCATION_LEFT = 0x01;

variable DOM_KEY_LOCATION_RIGHT

const unsigned long DOM_KEY_LOCATION_RIGHT = 0x02;

variable DOM_KEY_LOCATION_NUMPAD

const unsigned long DOM_KEY_LOCATION_NUMPAD = 0x03;

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

readonly attribute unsigned long keyCode;

variable which

readonly attribute unsigned long which;

variable key

readonly attribute DOMString key;

variable code

readonly attribute DOMString code;

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

readonly attribute boolean repeat;

Returns a boolean representing if the event is repeating (the user is holding the key down).

variable ctrlKey

readonly attribute boolean ctrlKey;

variable shiftKey

readonly attribute boolean shiftKey;

variable altKey

readonly attribute boolean altKey;

variable metaKey

readonly attribute boolean metaKey;