Skip to main content
Tools

Keyboard Event Codes

Press any key to see its JavaScript key, code, keyCode, location and modifiers, and watch IME composition events as you type.

Last key pressed

Press any key

With an IME such as Zhuyin or Cangjie, keydown events during composition have key “Process”, keyCode 229 and isComposing true. Read the chosen text from compositionend or input events, not from keydown.

So you do not leave the page and lose the log by accident, the tool only blocks keys that go back or reload (Alt + ←/→, Backspace, F5, Ctrl/⌘ + R). Every other key works as usual.

Event log

No events yet. Press any key.

Common keys

key changes with the keyboard layout and Shift; code is the physical key position and does not. The table assumes a US layout. keyCode and which are deprecated; use key or code in new code.

keycodekeyCode
EnterEnter13
EscapeEscape27
TabTab9
" "Space32
BackspaceBackspace8
DeleteDelete46
ArrowLeftArrowLeft37
ArrowUpArrowUp38
ArrowRightArrowRight39
ArrowDownArrowDown40
HomeHome36
EndEnd35
PageUpPageUp33
PageDownPageDown34
ShiftShiftLeft16
ControlControlLeft17
AltAltLeft18
MetaMetaLeft91
CapsLockCapsLock20
F1F1112
F12F12123
"a"KeyA65
"z"KeyZ90
"0"Digit048
"9"Digit957
"0"Numpad096
EnterNumpadEnter13
"-"Minus189
"="Equal187
","Comma188
"."Period190
"/"Slash191
";"Semicolon186
"'"Quote222
"["BracketLeft219
"\\"Backslash220
"`"Backquote192

How to use

  1. Press any key on the page. It appears in large type with its event.key, event.code, keyCode, which, location and modifiers.
  2. To test an IME, click into the text field and switch to an input method such as Zhuyin or Cangjie, then watch compositionstart, compositionupdate, compositionend and input in the event log as you type.
  3. To record the Tab key, turn on “Capture the Tab key”: Tab in the field then does not move focus. Press Esc to release it at once.
  4. Click “Copy log” to copy the event log as text for a bug report.

FAQ

What is the difference between key, code and keyCode?

key is the value the key produces, which depends on the layout, Shift and the IME: the same key can give “a” or “A”. code is the physical key position, such as “KeyA”, regardless of layout, which suits WASD game controls. keyCode and which are old numeric codes that differ between browsers and are deprecated; use key or code in new code.

Why is key “Process” and keyCode 229 while typing with an IME?

During IME composition, keys go to the input method first, so keydown reports key “Process”, keyCode 229 and isComposing true. An Enter at this point usually picks a character rather than submitting, so check event.isComposing before treating Enter as “send”, or Chinese, Japanese and Korean users will submit by accident.

What are composition events?

compositionstart fires when the IME starts composing, compositionupdate whenever the composition changes (data is the current phonetic or radical input) and compositionend when text is chosen (data is the final text). To get what the user actually typed, use compositionend or input events, not keydown.

Why do some keys do nothing or get caught by the browser?

The operating system and browser reserve some shortcuts, such as Ctrl/⌘ + W to close a tab or Ctrl/⌘ + T for a new tab; pages cannot block them or even see them. This tool only blocks keys that go back or reload, so you do not leave and lose the log by accident; every other key keeps its normal behavior.

Why is Tab not captured by default?

Tab is how keyboard users move focus, and capturing it permanently traps people on the page, which is an accessibility failure. Capture it only when you need to, and only inside the text field; Esc releases it.

What does location mean?

It tells apart keys with the same meaning in different places: 0 is a standard key, 1 the left one (like left Shift), 2 the right one (like right Ctrl) and 3 the numeric keypad (like the keypad Enter and 0).

Keyboard shortcuts

/
Search tools (on a tool page, goes to the homepage search)
?
Show this help
Esc
Close a dialog
Ctrl / ⌘Enter
Run the tool's main action (where supported)

While you type in a text field, / and ? are typed as usual.