Keycode finder

Press any key to see its JavaScript keyCode, key, code and location, and copy a ready keydown handler. Free, no sign-up, and it runs in your browser.

Click or tap the box, then press a key or a shortcut. Tab still moves to the next field.

Press a key in the box above to see its keyCode, key, code and location.

Keycode list

Values for a US keyboard in Chrome, Edge and Safari. Search by key name, code or keyCode number.

Keyevent.keyevent.codekeyCode
BackspaceBackspaceBackspace8
TabTabTab9
EnterEnterEnter13
Shift (left)ShiftShiftLeft16
Shift (right)ShiftShiftRight16
Ctrl (left)ControlControlLeft17
Ctrl (right)ControlControlRight17
Alt / Option (left)AltAltLeft18
Alt / Option (right)AltAltRight18
PausePausePause19
Caps LockCapsLockCapsLock20
EscapeEscapeEscape27
Space' 'Space32
Page UpPageUpPageUp33
Page DownPageDownPageDown34
EndEndEnd35
HomeHomeHome36
Arrow leftArrowLeftArrowLeft37
Arrow upArrowUpArrowUp38
Arrow rightArrowRightArrowRight39
Arrow downArrowDownArrowDown40
InsertInsertInsert45
DeleteDeleteDelete46
00Digit048
11Digit149
22Digit250
33Digit351
44Digit452
55Digit553
66Digit654
77Digit755
88Digit856
99Digit957
AaKeyA65
BbKeyB66
CcKeyC67
DdKeyD68
EeKeyE69
FfKeyF70
GgKeyG71
HhKeyH72
IiKeyI73
JjKeyJ74
KkKeyK75
LlKeyL76
MmKeyM77
NnKeyN78
OoKeyO79
PpKeyP80
QqKeyQ81
RrKeyR82
SsKeyS83
TtKeyT84
UuKeyU85
VvKeyV86
WwKeyW87
XxKeyX88
YyKeyY89
ZzKeyZ90
Windows / Command (left)MetaMetaLeft91
Context menuContextMenuContextMenu93
Numpad 00Numpad096
Numpad 11Numpad197
Numpad 22Numpad298
Numpad 33Numpad399
Numpad 44Numpad4100
Numpad 55Numpad5101
Numpad 66Numpad6102
Numpad 77Numpad7103
Numpad 88Numpad8104
Numpad 99Numpad9105
Numpad **NumpadMultiply106
Numpad ++NumpadAdd107
Numpad --NumpadSubtract109
Numpad ..NumpadDecimal110
Numpad //NumpadDivide111
F1F1F1112
F2F2F2113
F3F3F3114
F4F4F4115
F5F5F5116
F6F6F6117
F7F7F7118
F8F8F8119
F9F9F9120
F10F10F10121
F11F11F11122
F12F12F12123
Num LockNumLockNumLock144
Scroll LockScrollLockScrollLock145
; (semicolon);Semicolon186 (Firefox: 59)
= (equals)=Equal187 (Firefox: 61)
, (comma),Comma188
- (minus)-Minus189 (Firefox: 173)
. (period).Period190
/ (slash)/Slash191
` (backquote)`Backquote192
[ (left bracket)[BracketLeft219
\ (backslash)\Backslash220
] (right bracket)]BracketRight221
' (quote)'Quote222

What this keycode finder does

Press any key and the tool shows every value a JavaScript keydown event reports for it: keyCode, key, code, which and location, plus which modifier keys were held and whether the key was repeating. It also writes a ready keydown handler that matches the key you pressed, so you can paste it into your code. Below that is a searchable keycode list for a US keyboard.

The tool reads the same events your own code gets. Nothing you type is stored or sent anywhere.

How to use it

  1. Click or tap the box at the top, then press a key or a shortcut such as Ctrl+K or Shift+Enter.
  2. Read the big number for the old keyCode value, and the cards for key, code, which and location. Use the copy icon on a card to copy that value.
  3. Under Code for this key, choose whether to match event.key or event.code, then select Copy code.
  4. Press more keys to compare them in Recent keys. To look a key up without pressing it, search the Keycode list by name, code or number (for example 27 finds Escape).

Most browser shortcuts are blocked while the box has focus, so you can test keys such as Space, the arrow keys or Ctrl+S without the page reacting. Tab is not blocked, so you can still leave the box with the keyboard. A few system shortcuts, like closing the tab, can't be blocked by any web page.

key, code or keyCode: which one should you use?

  • event.key is the character or the name of the key, after the keyboard layout and modifiers are applied. Shift with 2 gives @ on a US layout but " on a UK layout.1 Use it for text and for shortcuts named after a letter, such as Ctrl+K. Special keys get fixed names like Enter, Escape or ArrowUp, defined in a W3C list.2
  • event.code is the physical key, and it does not change with the layout or with modifiers. KeyQ is the Q key on QWERTY, but the same key types A on AZERTY.3 Use it when position matters, such as WASD movement in a game.
  • event.keyCode and which are deprecated. MDN asks developers to avoid keyCode and to use key or code instead.4 It still works in every browser, which is why old code and many tutorials use it, but its numbers differ between browsers for some keys.

The location value tells keys with the same name apart: 0 is a standard key, 1 is the left key (left Shift), 2 is the right key, and 3 is the numeric keypad.5

If you style your own focus and key hints in CSS, the PX to REM converter and the CSS formatter help keep that code clean.

Frequently asked questions