KeyboardEvent objects describe a user interaction with the keyboard. Each event describes a key; the event type (keydown, keypress, or keyup) identifies what kind of activity was performed.

Documentation KeyboardEvent by Mozilla Contributors, licensed under CC-BY-SA 2.5.

See:

Constructor

new (typeArg:String, ?keyboardEventInitDict:KeyboardEventInit)

Throws:

null

DOMError

Variables

read onlyaltKey:Bool

Returns a Boolean that is true if the Alt ( Option or ⌥ on OS X) key was active when the key event was generated.

read onlycharCode:Int

Returns a Number representing the Unicode reference number of the key; this attribute is used only by the keypress event. For keys whose char attribute contains multiple characters, this is the Unicode value of the first character in that attribute. In Firefox 26 this returns codes for printable characters. Warning: This attribute is deprecated; you should use KeyboardEvent.key instead, if available.

read onlyctrlKey:Bool

Returns a Boolean that is true if the Ctrl key was active when the key event was generated.

read onlyisComposing:Bool

Returns a Boolean that is true if the event is fired between after compositionstart and before compositionend.

read onlykey:String

Returns a DOMString representing the key value of the key represented by the event.

read onlykeyCode:Int

Returns a Number representing a system and implementation dependent numerical code identifying the unmodified value of the pressed key. Warning: This attribute is deprecated; you should use KeyboardEvent.key instead, if available.

read onlylocation:Int

Returns a Number representing the location of the key on the keyboard or other input device.

read onlymetaKey:Bool

Returns a Boolean that is true if the Meta key (on Mac keyboards, the ⌘ Command key; on Windows keyboards, the Windows key (⊞)) was active when the key event was generated.

read onlyrepeat:Bool

Returns a Boolean that is true if the key is being held down such that it is automatically repeating.

read onlyshiftKey:Bool

Returns a Boolean that is true if the Shift key was active when the key event was generated.

Methods

getModifierState (key:String):Bool

Returns a Boolean indicating if the modifier key, like Alt, Shift, Ctrl, or Meta, was pressed when the event was created.

initKeyEvent (type:String, canBubble:Bool, cancelable:Bool, view:Window, ctrlKey:Bool, altKey:Bool, shiftKey:Bool, metaKey:Bool, keyCode:Int, charCode:Int):Void

Initializes a KeyboardEvent object. This has only been implemented by Gecko (others used KeyboardEvent.initKeyboardEvent()) and should not be used any more. The standard modern way is to use the KeyboardEvent.KeyboardEvent constructor.

Static variables

staticinline read onlyDOM_KEY_LOCATION_LEFT:Int = 1

staticinline read onlyDOM_KEY_LOCATION_NUMPAD:Int = 3

staticinline read onlyDOM_KEY_LOCATION_RIGHT:Int = 2

staticinline read onlyDOM_KEY_LOCATION_STANDARD:Int = 0

staticinline read onlyDOM_VK_0:Int = 48

staticinline read onlyDOM_VK_1:Int = 49

staticinline read onlyDOM_VK_2:Int = 50

staticinline read onlyDOM_VK_3:Int = 51

staticinline read onlyDOM_VK_4:Int = 52

staticinline read onlyDOM_VK_5:Int = 53

staticinline read onlyDOM_VK_6:Int = 54

staticinline read onlyDOM_VK_7:Int = 55

staticinline read onlyDOM_VK_8:Int = 56

staticinline read onlyDOM_VK_9:Int = 57

staticinline read onlyDOM_VK_A:Int = 65

staticinline read onlyDOM_VK_ACCEPT:Int = 30

staticinline read onlyDOM_VK_ADD:Int = 107

staticinline read onlyDOM_VK_ALT:Int = 18

staticinline read onlyDOM_VK_ALTGR:Int = 225

staticinline read onlyDOM_VK_AMPERSAND:Int = 166

staticinline read onlyDOM_VK_ASTERISK:Int = 170

staticinline read onlyDOM_VK_AT:Int = 64

staticinline read onlyDOM_VK_ATTN:Int = 246

staticinline read onlyDOM_VK_B:Int = 66

staticinline read onlyDOM_VK_BACK_QUOTE:Int = 192

staticinline read onlyDOM_VK_BACK_SLASH:Int = 220

staticinline read onlyDOM_VK_BACK_SPACE:Int = 8

staticinline read onlyDOM_VK_C:Int = 67

staticinline read onlyDOM_VK_CANCEL:Int = 3

staticinline read onlyDOM_VK_CAPS_LOCK:Int = 20

staticinline read onlyDOM_VK_CIRCUMFLEX:Int = 160

staticinline read onlyDOM_VK_CLEAR:Int = 12

staticinline read onlyDOM_VK_CLOSE_BRACKET:Int = 221

staticinline read onlyDOM_VK_CLOSE_CURLY_BRACKET:Int = 175

staticinline read onlyDOM_VK_CLOSE_PAREN:Int = 169

staticinline read onlyDOM_VK_COLON:Int = 58

staticinline read onlyDOM_VK_COMMA:Int = 188

staticinline read onlyDOM_VK_CONTEXT_MENU:Int = 93

staticinline read onlyDOM_VK_CONTROL:Int = 17

staticinline read onlyDOM_VK_CONVERT:Int = 28

staticinline read onlyDOM_VK_CRSEL:Int = 247

staticinline read onlyDOM_VK_D:Int = 68

staticinline read onlyDOM_VK_DECIMAL:Int = 110

staticinline read onlyDOM_VK_DELETE:Int = 46

staticinline read onlyDOM_VK_DIVIDE:Int = 111

staticinline read onlyDOM_VK_DOLLAR:Int = 164

staticinline read onlyDOM_VK_DOUBLE_QUOTE:Int = 162

staticinline read onlyDOM_VK_DOWN:Int = 40

staticinline read onlyDOM_VK_E:Int = 69

staticinline read onlyDOM_VK_EISU:Int = 22

staticinline read onlyDOM_VK_END:Int = 35

staticinline read onlyDOM_VK_EQUALS:Int = 61

staticinline read onlyDOM_VK_EREOF:Int = 249

staticinline read onlyDOM_VK_ESCAPE:Int = 27

staticinline read onlyDOM_VK_EXCLAMATION:Int = 161

staticinline read onlyDOM_VK_EXECUTE:Int = 43

staticinline read onlyDOM_VK_EXSEL:Int = 248

staticinline read onlyDOM_VK_F:Int = 70

staticinline read onlyDOM_VK_F1:Int = 112

staticinline read onlyDOM_VK_F10:Int = 121

staticinline read onlyDOM_VK_F11:Int = 122

staticinline read onlyDOM_VK_F12:Int = 123

staticinline read onlyDOM_VK_F13:Int = 124

staticinline read onlyDOM_VK_F14:Int = 125

staticinline read onlyDOM_VK_F15:Int = 126

staticinline read onlyDOM_VK_F16:Int = 127

staticinline read onlyDOM_VK_F17:Int = 128

staticinline read onlyDOM_VK_F18:Int = 129

staticinline read onlyDOM_VK_F19:Int = 130

staticinline read onlyDOM_VK_F2:Int = 113

staticinline read onlyDOM_VK_F20:Int = 131

staticinline read onlyDOM_VK_F21:Int = 132

staticinline read onlyDOM_VK_F22:Int = 133

staticinline read onlyDOM_VK_F23:Int = 134

staticinline read onlyDOM_VK_F24:Int = 135

staticinline read onlyDOM_VK_F3:Int = 114

staticinline read onlyDOM_VK_F4:Int = 115

staticinline read onlyDOM_VK_F5:Int = 116

staticinline read onlyDOM_VK_F6:Int = 117

staticinline read onlyDOM_VK_F7:Int = 118

staticinline read onlyDOM_VK_F8:Int = 119

staticinline read onlyDOM_VK_F9:Int = 120

staticinline read onlyDOM_VK_FINAL:Int = 24

staticinline read onlyDOM_VK_G:Int = 71

staticinline read onlyDOM_VK_GREATER_THAN:Int = 62

staticinline read onlyDOM_VK_H:Int = 72

staticinline read onlyDOM_VK_HANGUL:Int = 21

staticinline read onlyDOM_VK_HANJA:Int = 25

staticinline read onlyDOM_VK_HASH:Int = 163

staticinline read onlyDOM_VK_HELP:Int = 6

staticinline read onlyDOM_VK_HOME:Int = 36

staticinline read onlyDOM_VK_HYPHEN_MINUS:Int = 173

staticinline read onlyDOM_VK_I:Int = 73

staticinline read onlyDOM_VK_INSERT:Int = 45

staticinline read onlyDOM_VK_J:Int = 74

staticinline read onlyDOM_VK_JUNJA:Int = 23

staticinline read onlyDOM_VK_K:Int = 75

staticinline read onlyDOM_VK_KANA:Int = 21

staticinline read onlyDOM_VK_KANJI:Int = 25

staticinline read onlyDOM_VK_L:Int = 76

staticinline read onlyDOM_VK_LEFT:Int = 37

staticinline read onlyDOM_VK_LESS_THAN:Int = 60

staticinline read onlyDOM_VK_M:Int = 77

staticinline read onlyDOM_VK_META:Int = 224

staticinline read onlyDOM_VK_MODECHANGE:Int = 31

staticinline read onlyDOM_VK_MULTIPLY:Int = 106

staticinline read onlyDOM_VK_N:Int = 78

staticinline read onlyDOM_VK_NONCONVERT:Int = 29

staticinline read onlyDOM_VK_NUMPAD0:Int = 96

staticinline read onlyDOM_VK_NUMPAD1:Int = 97

staticinline read onlyDOM_VK_NUMPAD2:Int = 98

staticinline read onlyDOM_VK_NUMPAD3:Int = 99

staticinline read onlyDOM_VK_NUMPAD4:Int = 100

staticinline read onlyDOM_VK_NUMPAD5:Int = 101

staticinline read onlyDOM_VK_NUMPAD6:Int = 102

staticinline read onlyDOM_VK_NUMPAD7:Int = 103

staticinline read onlyDOM_VK_NUMPAD8:Int = 104

staticinline read onlyDOM_VK_NUMPAD9:Int = 105

staticinline read onlyDOM_VK_NUM_LOCK:Int = 144

staticinline read onlyDOM_VK_O:Int = 79

staticinline read onlyDOM_VK_OPEN_BRACKET:Int = 219

staticinline read onlyDOM_VK_OPEN_CURLY_BRACKET:Int = 174

staticinline read onlyDOM_VK_OPEN_PAREN:Int = 168

staticinline read onlyDOM_VK_P:Int = 80

staticinline read onlyDOM_VK_PA1:Int = 253

staticinline read onlyDOM_VK_PAGE_DOWN:Int = 34

staticinline read onlyDOM_VK_PAGE_UP:Int = 33

staticinline read onlyDOM_VK_PAUSE:Int = 19

staticinline read onlyDOM_VK_PERCENT:Int = 165

staticinline read onlyDOM_VK_PERIOD:Int = 190

staticinline read onlyDOM_VK_PIPE:Int = 172

staticinline read onlyDOM_VK_PLAY:Int = 250

staticinline read onlyDOM_VK_PLUS:Int = 171

staticinline read onlyDOM_VK_PRINT:Int = 42

staticinline read onlyDOM_VK_PRINTSCREEN:Int = 44

staticinline read onlyDOM_VK_Q:Int = 81

staticinline read onlyDOM_VK_QUESTION_MARK:Int = 63

staticinline read onlyDOM_VK_QUOTE:Int = 222

staticinline read onlyDOM_VK_R:Int = 82

staticinline read onlyDOM_VK_RETURN:Int = 13

staticinline read onlyDOM_VK_RIGHT:Int = 39

staticinline read onlyDOM_VK_S:Int = 83

staticinline read onlyDOM_VK_SCROLL_LOCK:Int = 145

staticinline read onlyDOM_VK_SELECT:Int = 41

staticinline read onlyDOM_VK_SEMICOLON:Int = 59

staticinline read onlyDOM_VK_SEPARATOR:Int = 108

staticinline read onlyDOM_VK_SHIFT:Int = 16

staticinline read onlyDOM_VK_SLASH:Int = 191

staticinline read onlyDOM_VK_SLEEP:Int = 95

staticinline read onlyDOM_VK_SPACE:Int = 32

staticinline read onlyDOM_VK_SUBTRACT:Int = 109

staticinline read onlyDOM_VK_T:Int = 84

staticinline read onlyDOM_VK_TAB:Int = 9

staticinline read onlyDOM_VK_TILDE:Int = 176

staticinline read onlyDOM_VK_U:Int = 85

staticinline read onlyDOM_VK_UNDERSCORE:Int = 167

staticinline read onlyDOM_VK_UP:Int = 38

staticinline read onlyDOM_VK_V:Int = 86

staticinline read onlyDOM_VK_VOLUME_DOWN:Int = 182

staticinline read onlyDOM_VK_VOLUME_MUTE:Int = 181

staticinline read onlyDOM_VK_VOLUME_UP:Int = 183

staticinline read onlyDOM_VK_W:Int = 87

staticinline read onlyDOM_VK_WIN:Int = 91

staticinline read onlyDOM_VK_WIN_ICO_00:Int = 228

staticinline read onlyDOM_VK_WIN_ICO_CLEAR:Int = 230

staticinline read onlyDOM_VK_WIN_ICO_HELP:Int = 227

staticinline read onlyDOM_VK_WIN_OEM_ATTN:Int = 240

staticinline read onlyDOM_VK_WIN_OEM_AUTO:Int = 243

staticinline read onlyDOM_VK_WIN_OEM_BACKTAB:Int = 245

staticinline read onlyDOM_VK_WIN_OEM_CLEAR:Int = 254

staticinline read onlyDOM_VK_WIN_OEM_COPY:Int = 242

staticinline read onlyDOM_VK_WIN_OEM_CUSEL:Int = 239

staticinline read onlyDOM_VK_WIN_OEM_ENLW:Int = 244

staticinline read onlyDOM_VK_WIN_OEM_FINISH:Int = 241

staticinline read onlyDOM_VK_WIN_OEM_FJ_JISHO:Int = 146

staticinline read onlyDOM_VK_WIN_OEM_FJ_LOYA:Int = 149

staticinline read onlyDOM_VK_WIN_OEM_FJ_MASSHOU:Int = 147

staticinline read onlyDOM_VK_WIN_OEM_FJ_ROYA:Int = 150

staticinline read onlyDOM_VK_WIN_OEM_FJ_TOUROKU:Int = 148

staticinline read onlyDOM_VK_WIN_OEM_JUMP:Int = 234

staticinline read onlyDOM_VK_WIN_OEM_PA1:Int = 235

staticinline read onlyDOM_VK_WIN_OEM_PA2:Int = 236

staticinline read onlyDOM_VK_WIN_OEM_PA3:Int = 237

staticinline read onlyDOM_VK_WIN_OEM_RESET:Int = 233

staticinline read onlyDOM_VK_WIN_OEM_WSCTRL:Int = 238

staticinline read onlyDOM_VK_X:Int = 88

staticinline read onlyDOM_VK_Y:Int = 89

staticinline read onlyDOM_VK_Z:Int = 90

staticinline read onlyDOM_VK_ZOOM:Int = 251

Inherited Variables

Defined by UIEvent

cancelBubble:Bool

Is a Boolean indicating whether the bubbling of the event has been canceled or not.

read onlydetail:Int

Returns a long with details about the event, depending on the event type.

read onlyisChar:Bool

Returns a Boolean indicating whether the event produced a key character or not.

read onlylayerX:Int

Returns the horizontal coordinate of the event relative to the current layer.

read onlylayerY:Int

Returns the vertical coordinate of the event relative to the current layer.

read onlypageX:Int

Returns the horizontal coordinate of the event relative to the whole document.

read onlypageY:Int

Returns the vertical coordinate of the event relative to the whole document.

read onlyrangeOffset:Int

read onlyrangeParent:Node

read onlyview:Window

Returns a WindowProxy that contains the view that generated the event.

read onlywhich:Int

Returns the numeric keyCode of the key pressed, or the character code (charCode) for an alphanumeric key pressed.

Defined by Event

read onlybubbles:Bool

A Boolean indicating whether the event bubbles up through the DOM or not.

read onlycancelable:Bool

A Boolean indicating whether the event is cancelable.

read onlycurrentTarget:EventTarget

A reference to the currently registered target for the event. This is the object to which the event is currently slated to be sent to; it's possible this has been changed along the way through retargeting.

read onlydefaultPrevented:Bool

Indicates whether or not event.preventDefault() has been called on the event.

read onlyeventPhase:Int

Indicates which phase of the event flow is being processed.

read onlyexplicitOriginalTarget:EventTarget

The explicit original target of the event (Mozilla-specific).

read onlyisTrusted:Bool

Indicates whether or not the event was initiated by the browser (after a user click for instance) or by a script (using an event creation method, like event.initEvent)

read onlyoriginalTarget:EventTarget

The original target of the event, before any retargetings (Mozilla-specific).

read onlytarget:EventTarget

A reference to the target to which the event was originally dispatched.

read onlytimeStamp:Float

The time at which the event was created, in milliseconds. By specification, this value is time since epoch, but in reality browsers' definitions vary; in addition, work is underway to change this to be a DOMHighResTimeStamp instead.

read onlytype:String

The name of the event (case-insensitive).

Inherited Methods

Defined by UIEvent

initUIEvent (aType:String, aCanBubble:Bool, aCancelable:Bool, aView:Window, aDetail:Int):Void

Initializes a UIEvent object. If the event has already being dispatched, this method does nothing.

Defined by Event

getPreventDefault ():Bool

Non-standard. Returns the value of Event.defaultPrevented. Use Event.defaultPrevented instead.

initEvent (type:String, bubbles:Bool, cancelable:Bool):Void

Initializes the value of an Event created. If the event has already being dispatched, this method does nothing.

preventDefault ():Void

Cancels the event (if it is cancelable).

stopImmediatePropagation ():Void

For this particular event, no other listener will be called. Neither those attached on the same element, nor those attached on elements which will be traversed later (in capture phase, for instance)

stopPropagation ():Void

Stops the propagation of events further along in the DOM.