Open dataset

JavaScript key code reference table

Every event.key, event.code and legacy keyCode value for a US QWERTY keyboard, in one place, with the inconsistencies marked instead of hidden.

event.code names the physical key and never changes with your keyboard layout. event.key is the character that layout produces, so it does change, and it changes again when you hold Shift. keyCode is the deprecated legacy model, and for several keys, including Meta, there is no single value that is correct across browsers. The table below carries all three, with a note on every row where the answer is not the same everywhere.

Reuse and attribution

This table is published under CC BY 4.0. Quote it, embed it, ship it in your own documentation. All that is asked is a link back to https://mygearcheck.com/data/key-codes so the next person can check whether it has changed.

How this table was built and what it covers

The code and key columns follow the W3C UI Events specifications for code values and key values, read 2026-08-05. The keyCode column holds the values the major browsers report on Windows and Linux under the legacy key model. Where a value is known to differ by browser or by operating system, the row carries a note and, where there is genuinely no stable answer, the cell is empty rather than filled with a plausible guess.

The key column is the unshifted result on a US QWERTY (ANSI) layout. On any other layout the same physical key produces a different character while the code stays identical, which is the entire reason code exists.

Letters: 26 keys
event.keyevent.codekeyCode (deprecated)Note
aKeyA65
bKeyB66
cKeyC67
dKeyD68
eKeyE69
fKeyF70
gKeyG71
hKeyH72
iKeyI73
jKeyJ74
kKeyK75
lKeyL76
mKeyM77
nKeyN78
oKeyO79
pKeyP80
qKeyQ81
rKeyR82
sKeyS83
tKeyT84
uKeyU85
vKeyV86
wKeyW87
xKeyX88
yKeyY89
zKeyZ90
Digits: 10 keys
event.keyevent.codekeyCode (deprecated)Note
0Digit048
1Digit149
2Digit250
3Digit351
4Digit452
5Digit553
6Digit654
7Digit755
8Digit856
9Digit957
Punctuation: 14 keys
event.keyevent.codekeyCode (deprecated)Note
`Backquote192
-Minus189
=Equal187
[BracketLeft219
]BracketRight221
\Backslash220
;Semicolon186
'Quote222
,Comma188
.Period190
/Slash191
\IntlBackslash226The extra key next to the left Shift on ISO (European) keyboards. Absent on ANSI boards.
\IntlRo193Japanese layouts only.
¥IntlYen255Japanese layouts only. The keyCode is not consistent across browsers.
Whitespace and editing: 6 keys
event.keyevent.codekeyCode (deprecated)Note
(space)Space32event.key is a single space character.
EnterEnter13
TabTab9
BackspaceBackspace8
DeleteDelete46
InsertInsert45
Navigation: 8 keys
event.keyevent.codekeyCode (deprecated)Note
ArrowUpArrowUp38
ArrowDownArrowDown40
ArrowLeftArrowLeft37
ArrowRightArrowRight39
HomeHome36
EndEnd35
PageUpPageUp33
PageDownPageDown34
Modifiers: 9 keys
event.keyevent.codekeyCode (deprecated)Note
ShiftShiftLeft16Left and right Shift share keyCode 16. Only event.code (or the older event.location) tells them apart.
ShiftShiftRight16
ControlControlLeft17Left and right Control share keyCode 17.
ControlControlRight17
AltAltLeft18On macOS this is the Option key. event.key is still "Alt".
AltAltRight18On many European layouts this key acts as AltGr and produces a character instead of a bare modifier.
MetaMetaLeftno stable valueWindows key, Command on macOS, Super on Linux. keyCode is not stable: browsers have reported 91, 93 and 224 for this key depending on OS and version. Use event.code or event.metaKey.
MetaMetaRightno stable valueSame instability as MetaLeft.
ContextMenuContextMenu93The menu key right of the space bar on many Windows keyboards.
Function keys: 12 keys
event.keyevent.codekeyCode (deprecated)Note
F1F1112
F2F2113
F3F3114
F4F4115
F5F5116
F6F6117
F7F7118
F8F8119
F9F9120
F10F10121
F11F11122
F12F12123
Numpad: 16 keys
event.keyevent.codekeyCode (deprecated)Note
0Numpad096With Num Lock off the numpad reports navigation keys instead.
1Numpad197
2Numpad298
3Numpad399
4Numpad4100
5Numpad5101
6Numpad6102
7Numpad7103
8Numpad8104
9Numpad9105
/NumpadDivide111
*NumpadMultiply106
-NumpadSubtract109
+NumpadAdd107
EnterNumpadEnter13Shares keyCode 13 with the main Enter. event.code is the only way to tell them apart.
.NumpadDecimal110Some layouts produce a comma here.
System and lock: 6 keys
event.keyevent.codekeyCode (deprecated)Note
EscapeEscape27
CapsLockCapsLock20
NumLockNumLock144
ScrollLockScrollLock145Intercepted by the OS on some systems, so the browser may never see it.
PausePause19Often swallowed by the OS or by the browser's own shortcuts.
PrintScreenPrintScreen44Windows and most Linux desktops handle this key themselves. Many browsers only ever see the keyup, never the keydown.

Changelog

The dataset is versioned, and the version number in the JSON response changes with the contents. If you find an error, report it: corrections are made and recorded here.