KeyboardEvent
KeyboardEvent objects describe a user interaction with the keyboard; each event describes a single interaction between the user and a key (or combination of a key with modifier keys) on the keyboard.
Documentation KeyboardEvent by Mozilla Contributors, licensed under CC-BY-SA 2.5.
Static Members
DOM_KEY_LOCATION_STANDARD: IntDOM_KEY_LOCATION_LEFT: IntDOM_KEY_LOCATION_RIGHT: IntDOM_KEY_LOCATION_NUMPAD: IntDOM_VK_CANCEL: IntDOM_VK_HELP: IntDOM_VK_BACK_SPACE: IntDOM_VK_TAB: IntDOM_VK_CLEAR: IntDOM_VK_RETURN: IntDOM_VK_SHIFT: IntDOM_VK_CONTROL: IntDOM_VK_ALT: IntDOM_VK_PAUSE: IntDOM_VK_CAPS_LOCK: IntDOM_VK_KANA: IntDOM_VK_HANGUL: IntDOM_VK_EISU: IntDOM_VK_JUNJA: IntDOM_VK_FINAL: IntDOM_VK_HANJA: IntDOM_VK_KANJI: IntDOM_VK_ESCAPE: IntDOM_VK_CONVERT: IntDOM_VK_NONCONVERT: IntDOM_VK_ACCEPT: IntDOM_VK_MODECHANGE: IntDOM_VK_SPACE: IntDOM_VK_PAGE_UP: IntDOM_VK_PAGE_DOWN: IntDOM_VK_END: IntDOM_VK_HOME: IntDOM_VK_LEFT: IntDOM_VK_UP: IntDOM_VK_RIGHT: IntDOM_VK_DOWN: IntDOM_VK_SELECT: IntDOM_VK_PRINT: IntDOM_VK_EXECUTE: IntDOM_VK_PRINTSCREEN: IntDOM_VK_INSERT: IntDOM_VK_DELETE: IntDOM_VK_0: IntDOM_VK_1: IntDOM_VK_2: IntDOM_VK_3: IntDOM_VK_4: IntDOM_VK_5: IntDOM_VK_6: IntDOM_VK_7: IntDOM_VK_8: IntDOM_VK_9: IntDOM_VK_COLON: IntDOM_VK_SEMICOLON: IntDOM_VK_LESS_THAN: IntDOM_VK_EQUALS: IntDOM_VK_GREATER_THAN: IntDOM_VK_QUESTION_MARK: IntDOM_VK_AT: IntDOM_VK_A: IntDOM_VK_B: IntDOM_VK_C: IntDOM_VK_D: IntDOM_VK_E: IntDOM_VK_F: IntDOM_VK_G: IntDOM_VK_H: IntDOM_VK_I: IntDOM_VK_J: IntDOM_VK_K: IntDOM_VK_L: IntDOM_VK_M: IntDOM_VK_N: IntDOM_VK_O: IntDOM_VK_P: IntDOM_VK_Q: IntDOM_VK_R: IntDOM_VK_S: IntDOM_VK_T: IntDOM_VK_U: IntDOM_VK_V: IntDOM_VK_W: IntDOM_VK_X: IntDOM_VK_Y: IntDOM_VK_Z: IntDOM_VK_WIN: IntDOM_VK_CONTEXT_MENU: IntDOM_VK_SLEEP: IntDOM_VK_NUMPAD0: IntDOM_VK_NUMPAD1: IntDOM_VK_NUMPAD2: IntDOM_VK_NUMPAD3: IntDOM_VK_NUMPAD4: IntDOM_VK_NUMPAD5: IntDOM_VK_NUMPAD6: IntDOM_VK_NUMPAD7: IntDOM_VK_NUMPAD8: IntDOM_VK_NUMPAD9: IntDOM_VK_MULTIPLY: IntDOM_VK_ADD: IntDOM_VK_SEPARATOR: IntDOM_VK_SUBTRACT: IntDOM_VK_DECIMAL: IntDOM_VK_DIVIDE: IntDOM_VK_F1: IntDOM_VK_F2: IntDOM_VK_F3: IntDOM_VK_F4: IntDOM_VK_F5: IntDOM_VK_F6: IntDOM_VK_F7: IntDOM_VK_F8: IntDOM_VK_F9: IntDOM_VK_F10: IntDOM_VK_F11: IntDOM_VK_F12: IntDOM_VK_F13: IntDOM_VK_F14: IntDOM_VK_F15: IntDOM_VK_F16: IntDOM_VK_F17: IntDOM_VK_F18: IntDOM_VK_F19: IntDOM_VK_F20: IntDOM_VK_F21: IntDOM_VK_F22: IntDOM_VK_F23: IntDOM_VK_F24: IntDOM_VK_NUM_LOCK: IntDOM_VK_SCROLL_LOCK: IntDOM_VK_WIN_OEM_FJ_JISHO: IntDOM_VK_WIN_OEM_FJ_MASSHOU: IntDOM_VK_WIN_OEM_FJ_TOUROKU: IntDOM_VK_WIN_OEM_FJ_LOYA: IntDOM_VK_WIN_OEM_FJ_ROYA: IntDOM_VK_CIRCUMFLEX: IntDOM_VK_EXCLAMATION: IntDOM_VK_DOUBLE_QUOTE: IntDOM_VK_HASH: IntDOM_VK_DOLLAR: IntDOM_VK_PERCENT: IntDOM_VK_AMPERSAND: IntDOM_VK_UNDERSCORE: IntDOM_VK_OPEN_PAREN: IntDOM_VK_CLOSE_PAREN: IntDOM_VK_ASTERISK: IntDOM_VK_PLUS: IntDOM_VK_PIPE: IntDOM_VK_HYPHEN_MINUS: IntDOM_VK_OPEN_CURLY_BRACKET: IntDOM_VK_CLOSE_CURLY_BRACKET: IntDOM_VK_TILDE: IntDOM_VK_VOLUME_MUTE: IntDOM_VK_VOLUME_DOWN: IntDOM_VK_VOLUME_UP: IntDOM_VK_COMMA: IntDOM_VK_PERIOD: IntDOM_VK_SLASH: IntDOM_VK_BACK_QUOTE: IntDOM_VK_OPEN_BRACKET: IntDOM_VK_BACK_SLASH: IntDOM_VK_CLOSE_BRACKET: IntDOM_VK_QUOTE: IntDOM_VK_META: IntDOM_VK_ALTGR: IntDOM_VK_WIN_ICO_HELP: IntDOM_VK_WIN_ICO_00: IntDOM_VK_PROCESSKEY: IntDOM_VK_WIN_ICO_CLEAR: IntDOM_VK_WIN_OEM_RESET: IntDOM_VK_WIN_OEM_JUMP: IntDOM_VK_WIN_OEM_PA1: IntDOM_VK_WIN_OEM_PA2: IntDOM_VK_WIN_OEM_PA3: IntDOM_VK_WIN_OEM_WSCTRL: IntDOM_VK_WIN_OEM_CUSEL: IntDOM_VK_WIN_OEM_ATTN: IntDOM_VK_WIN_OEM_FINISH: IntDOM_VK_WIN_OEM_COPY: IntDOM_VK_WIN_OEM_AUTO: IntDOM_VK_WIN_OEM_ENLW: IntDOM_VK_WIN_OEM_BACKTAB: IntDOM_VK_ATTN: IntDOM_VK_CRSEL: IntDOM_VK_EXSEL: IntDOM_VK_EREOF: IntDOM_VK_PLAY: IntDOM_VK_ZOOM: IntDOM_VK_PA1: IntDOM_VK_WIN_OEM_CLEAR: IntInstance Members
charCode: IntReturns 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.
keyCode: IntReturns 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.
altKey: BoolReturns a Boolean that is true if the Alt ( Option or ⌥ on OS X) key was active when the key event was generated.
ctrlKey: BoolReturns a Boolean that is true if the Ctrl key was active when the key event was generated.
shiftKey: BoolReturns a Boolean that is true if the Shift key was active when the key event was generated.
metaKey: BoolReturns 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.
location: IntReturns a Number representing the location of the key on the keyboard or other input device.
repeat: BoolReturns a Boolean that is true if the key is being held down such that it is automatically repeating.
isComposing: BoolReturns a Boolean that is true if the event is fired between after compositionstart and before compositionend.
key: StringReturns a DOMString representing the key value of the key represented by the event.
code: StringReturns a DOMString with the code value of the key represented by the event.
Returns a Boolean indicating if a modifier key such as Alt, Shift, Ctrl, or Meta, was pressed when the event was created.
| Name | Type |
|---|---|
key |
String |
| Returns |
|---|
| Bool |
initKeyboardEvent(typeArg: String, ?bubblesArg: Bool = false, ?cancelableArg: Bool = false, ?viewArg: Window, ?keyArg: String = "", ?locationArg: Int = 0, ?ctrlKey: Bool = false, ?altKey: Bool = false, ?shiftKey: Bool = false, ?metaKey: Bool = false): VoidInitializes a KeyboardEvent object. This is now deprecated. You should instead use the KeyboardEvent.KeyboardEvent constructor.
| Name | Type | Default |
|---|---|---|
typeArg |
String | |
bubblesArg |
Bool | false |
cancelableArg |
Bool | false |
viewArg |
Window | (optional) |
keyArg |
String | "" |
locationArg |
Int | 0 |
ctrlKey |
Bool | false |
altKey |
Bool | false |
shiftKey |
Bool | false |
metaKey |
Bool | false |
initKeyEvent(type: String, ?canBubble: Bool = false, ?cancelable: Bool = false, ?view: Window, ?ctrlKey: Bool = false, ?altKey: Bool = false, ?shiftKey: Bool = false, ?metaKey: Bool = false, ?keyCode: Int = 0, ?charCode: Int = 0): VoidInitializes a KeyboardEvent object. This was implemented only by Firefox, and is no longer supported even there; instead, you should use the KeyboardEvent.KeyboardEvent constructor.
| Name | Type | Default |
|---|---|---|
type |
String | |
canBubble |
Bool | false |
cancelable |
Bool | false |
view |
Window | (optional) |
ctrlKey |
Bool | false |
altKey |
Bool | false |
shiftKey |
Bool | false |
metaKey |
Bool | false |
keyCode |
Int | 0 |
charCode |
Int | 0 |
new(typeArg: String, ?keyboardEventInitDict: Null<KeyboardEventInit>): Void| Name | Type | Default |
|---|---|---|
typeArg |
String | |
keyboardEventInitDict |
Null<KeyboardEventInit> | (optional) |