KeyboardEvent

EventUIEventjs.html.KeyboardEvent (extern class)

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.

See:

Static Members

DOM_KEY_LOCATION_STANDARD: Int

DOM_KEY_LOCATION_LEFT: Int

DOM_KEY_LOCATION_RIGHT: Int

DOM_KEY_LOCATION_NUMPAD: Int

DOM_VK_CANCEL: Int

DOM_VK_HELP: Int

DOM_VK_BACK_SPACE: Int

DOM_VK_TAB: Int

DOM_VK_CLEAR: Int

DOM_VK_RETURN: Int

DOM_VK_SHIFT: Int

DOM_VK_CONTROL: Int

DOM_VK_ALT: Int

DOM_VK_PAUSE: Int

DOM_VK_CAPS_LOCK: Int

DOM_VK_KANA: Int

DOM_VK_HANGUL: Int

DOM_VK_EISU: Int

DOM_VK_JUNJA: Int

DOM_VK_FINAL: Int

DOM_VK_HANJA: Int

DOM_VK_KANJI: Int

DOM_VK_ESCAPE: Int

DOM_VK_CONVERT: Int

DOM_VK_NONCONVERT: Int

DOM_VK_ACCEPT: Int

DOM_VK_MODECHANGE: Int

DOM_VK_SPACE: Int

DOM_VK_PAGE_UP: Int

DOM_VK_PAGE_DOWN: Int

DOM_VK_END: Int

DOM_VK_HOME: Int

DOM_VK_LEFT: Int

DOM_VK_UP: Int

DOM_VK_RIGHT: Int

DOM_VK_DOWN: Int

DOM_VK_SELECT: Int

DOM_VK_PRINT: Int

DOM_VK_EXECUTE: Int

DOM_VK_PRINTSCREEN: Int

DOM_VK_INSERT: Int

DOM_VK_DELETE: Int

DOM_VK_0: Int

DOM_VK_1: Int

DOM_VK_2: Int

DOM_VK_3: Int

DOM_VK_4: Int

DOM_VK_5: Int

DOM_VK_6: Int

DOM_VK_7: Int

DOM_VK_8: Int

DOM_VK_9: Int

DOM_VK_COLON: Int

DOM_VK_SEMICOLON: Int

DOM_VK_LESS_THAN: Int

DOM_VK_EQUALS: Int

DOM_VK_GREATER_THAN: Int

DOM_VK_QUESTION_MARK: Int

DOM_VK_AT: Int

DOM_VK_A: Int

DOM_VK_B: Int

DOM_VK_C: Int

DOM_VK_D: Int

DOM_VK_E: Int

DOM_VK_F: Int

DOM_VK_G: Int

DOM_VK_H: Int

DOM_VK_I: Int

DOM_VK_J: Int

DOM_VK_K: Int

DOM_VK_L: Int

DOM_VK_M: Int

DOM_VK_N: Int

DOM_VK_O: Int

DOM_VK_P: Int

DOM_VK_Q: Int

DOM_VK_R: Int

DOM_VK_S: Int

DOM_VK_T: Int

DOM_VK_U: Int

DOM_VK_V: Int

DOM_VK_W: Int

DOM_VK_X: Int

DOM_VK_Y: Int

DOM_VK_Z: Int

DOM_VK_WIN: Int

DOM_VK_CONTEXT_MENU: Int

DOM_VK_SLEEP: Int

DOM_VK_NUMPAD0: Int

DOM_VK_NUMPAD1: Int

DOM_VK_NUMPAD2: Int

DOM_VK_NUMPAD3: Int

DOM_VK_NUMPAD4: Int

DOM_VK_NUMPAD5: Int

DOM_VK_NUMPAD6: Int

DOM_VK_NUMPAD7: Int

DOM_VK_NUMPAD8: Int

DOM_VK_NUMPAD9: Int

DOM_VK_MULTIPLY: Int

DOM_VK_ADD: Int

DOM_VK_SEPARATOR: Int

DOM_VK_SUBTRACT: Int

DOM_VK_DECIMAL: Int

DOM_VK_DIVIDE: Int

DOM_VK_F1: Int

DOM_VK_F2: Int

DOM_VK_F3: Int

DOM_VK_F4: Int

DOM_VK_F5: Int

DOM_VK_F6: Int

DOM_VK_F7: Int

DOM_VK_F8: Int

DOM_VK_F9: Int

DOM_VK_F10: Int

DOM_VK_F11: Int

DOM_VK_F12: Int

DOM_VK_F13: Int

DOM_VK_F14: Int

DOM_VK_F15: Int

DOM_VK_F16: Int

DOM_VK_F17: Int

DOM_VK_F18: Int

DOM_VK_F19: Int

DOM_VK_F20: Int

DOM_VK_F21: Int

DOM_VK_F22: Int

DOM_VK_F23: Int

DOM_VK_F24: Int

DOM_VK_NUM_LOCK: Int

DOM_VK_SCROLL_LOCK: Int

DOM_VK_WIN_OEM_FJ_JISHO: Int

DOM_VK_WIN_OEM_FJ_MASSHOU: Int

DOM_VK_WIN_OEM_FJ_TOUROKU: Int

DOM_VK_WIN_OEM_FJ_LOYA: Int

DOM_VK_WIN_OEM_FJ_ROYA: Int

DOM_VK_CIRCUMFLEX: Int

DOM_VK_EXCLAMATION: Int

DOM_VK_DOUBLE_QUOTE: Int

DOM_VK_HASH: Int

DOM_VK_DOLLAR: Int

DOM_VK_PERCENT: Int

DOM_VK_AMPERSAND: Int

DOM_VK_UNDERSCORE: Int

DOM_VK_OPEN_PAREN: Int

DOM_VK_CLOSE_PAREN: Int

DOM_VK_ASTERISK: Int

DOM_VK_PLUS: Int

DOM_VK_PIPE: Int

DOM_VK_HYPHEN_MINUS: Int

DOM_VK_OPEN_CURLY_BRACKET: Int

DOM_VK_CLOSE_CURLY_BRACKET: Int

DOM_VK_TILDE: Int

DOM_VK_VOLUME_MUTE: Int

DOM_VK_VOLUME_DOWN: Int

DOM_VK_VOLUME_UP: Int

DOM_VK_COMMA: Int

DOM_VK_PERIOD: Int

DOM_VK_SLASH: Int

DOM_VK_BACK_QUOTE: Int

DOM_VK_OPEN_BRACKET: Int

DOM_VK_BACK_SLASH: Int

DOM_VK_CLOSE_BRACKET: Int

DOM_VK_QUOTE: Int

DOM_VK_META: Int

DOM_VK_ALTGR: Int

DOM_VK_WIN_ICO_HELP: Int

DOM_VK_WIN_ICO_00: Int

DOM_VK_PROCESSKEY: Int

DOM_VK_WIN_ICO_CLEAR: Int

DOM_VK_WIN_OEM_RESET: Int

DOM_VK_WIN_OEM_JUMP: Int

DOM_VK_WIN_OEM_PA1: Int

DOM_VK_WIN_OEM_PA2: Int

DOM_VK_WIN_OEM_PA3: Int

DOM_VK_WIN_OEM_WSCTRL: Int

DOM_VK_WIN_OEM_CUSEL: Int

DOM_VK_WIN_OEM_ATTN: Int

DOM_VK_WIN_OEM_FINISH: Int

DOM_VK_WIN_OEM_COPY: Int

DOM_VK_WIN_OEM_AUTO: Int

DOM_VK_WIN_OEM_ENLW: Int

DOM_VK_WIN_OEM_BACKTAB: Int

DOM_VK_ATTN: Int

DOM_VK_CRSEL: Int

DOM_VK_EXSEL: Int

DOM_VK_EREOF: Int

DOM_VK_PLAY: Int

DOM_VK_ZOOM: Int

DOM_VK_PA1: Int

DOM_VK_WIN_OEM_CLEAR: Int

Instance Members

charCode: 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.


keyCode: 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.


altKey: Bool

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


ctrlKey: Bool

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


shiftKey: Bool

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


metaKey: 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.


location: Int

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


repeat: Bool

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


isComposing: Bool

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


key: String

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


code: String

Returns a DOMString with the code value of the key represented by the event.


getModifierState(key: String): Bool

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): Void

Initializes 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): Void

Initializes 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)