KeyCode class

Defines the keycode values for keys that are returned by KeyboardEvent.keyCode.

Defines the keycode values for keys that are returned by KeyboardEvent.keyCode.

Important note: There is substantial divergence in how different browsers handle keycodes and their variants in different locales/keyboard layouts. We provide these constants to help make code processing keys more readable.

Constructors

KeyCode ( )

Constants

WIN_KEY_FF_LINUX = 0
MAC_ENTER = 3
BACKSPACE = 8
TAB = 9
NUM_CENTER = 12
NUM_CENTER is also NUMLOCK for FF and Safari on Mac.
ENTER = 13
SHIFT = 16
CTRL = 17
ALT = 18
PAUSE = 19
CAPS_LOCK = 20
ESC = 27
SPACE = 32
PAGE_UP = 33
PAGE_DOWN = 34
END = 35
HOME = 36
LEFT = 37
UP = 38
DOWN = 40
NUM_NORTH_EAST = 33
NUM_SOUTH_EAST = 34
NUM_SOUTH_WEST = 35
NUM_NORTH_WEST = 36
NUM_WEST = 37
NUM_NORTH = 38
NUM_EAST = 39
NUM_SOUTH = 40
INSERT = 45
NUM_INSERT = 45
DELETE = 46
NUM_DELETE = 46
ZERO = 48
ONE = 49
TWO = 50
THREE = 51
FOUR = 52
FIVE = 53
SIX = 54
SEVEN = 55
EIGHT = 56
NINE = 57
FF_SEMICOLON = 59
FF_EQUALS = 61
QUESTION_MARK = 63
CAUTION: The question mark is for US-keyboard layouts. It varies for other locales and keyboard layouts.
A = 65
B = 66
C = 67
D = 68
E = 69
F = 70
G = 71
H = 72
I = 73
J = 74
K = 75
L = 76
M = 77
N = 78
O = 79
P = 80
Q = 81
R = 82
S = 83
T = 84
U = 85
V = 86
W = 87
X = 88
Y = 89
Z = 90
META = 91
WIN_KEY_LEFT = 91
WIN_KEY_RIGHT = 92
CONTEXT_MENU = 93
NUM_ZERO = 96
NUM_ONE = 97
NUM_TWO = 98
NUM_THREE = 99
NUM_FOUR = 100
NUM_FIVE = 101
NUM_SIX = 102
NUM_SEVEN = 103
NUM_EIGHT = 104
NUM_NINE = 105
NUM_MULTIPLY = 106
NUM_PLUS = 107
NUM_MINUS = 109
NUM_PERIOD = 110
NUM_DIVISION = 111
F1 = 112
F2 = 113
F3 = 114
F4 = 115
F5 = 116
F6 = 117
F7 = 118
F8 = 119
F9 = 120
F10 = 121
F11 = 122
F12 = 123
NUMLOCK = 144
SCROLL_LOCK = 145
FIRST_MEDIA_KEY = 166
LAST_MEDIA_KEY = 183
SEMICOLON = 186
CAUTION: This constant requires localization for other locales and keyboard layouts.
DASH = 189
CAUTION: This constant requires localization for other locales and keyboard layouts.
EQUALS = 187
CAUTION: This constant requires localization for other locales and keyboard layouts.
COMMA = 188
CAUTION: This constant requires localization for other locales and keyboard layouts.
PERIOD = 190
CAUTION: This constant requires localization for other locales and keyboard layouts.
SLASH = 191
CAUTION: This constant requires localization for other locales and keyboard layouts.
APOSTROPHE = 192
CAUTION: This constant requires localization for other locales and keyboard layouts.
TILDE = 192
CAUTION: This constant requires localization for other locales and keyboard layouts.
SINGLE_QUOTE = 222
CAUTION: This constant requires localization for other locales and keyboard layouts.
OPEN_SQUARE_BRACKET = 219
CAUTION: This constant requires localization for other locales and keyboard layouts.
BACKSLASH = 220
CAUTION: This constant requires localization for other locales and keyboard layouts.
CLOSE_SQUARE_BRACKET = 221
CAUTION: This constant requires localization for other locales and keyboard layouts.
WIN_KEY = 224
MAC_FF_META = 224
WIN_IME = 229
UNKNOWN = -1
A sentinel value if the keycode could not be determined.

Static Methods

isCharacterKey ( int keyCode ) → bool
Returns true if the keyCode produces a (US keyboard) character. Note: This does not (yet) cover characters on non-US keyboards (Russian, Hebrew, etc.).