Keyboardtest Logo

Keyboard Event & Code Reference

KeyboardEvent.code describes a physical key position; KeyboardEvent.key describes the interpreted character or action. Compare both in the live keyboard event inspector when a key produces the wrong letter or a numpad behaves differently from the number row.

Common physical codes

These are typical hardware-keyboard events. Layout, OS, input method and browser can change what is exposed; an empty or unidentified code is possible.

Typical browser codes, interpreted keys and key locations
Key positioncodekeylocation
A position on US QWERTYKeyAa / A / a layout-dependent character0
Number-row 1Digit11 or the shifted symbol0
Keypad 1Numpad11 or End, depending on Num Lock3
Main EnterEnterEnter0
Keypad EnterNumpadEnterEnter3
Left ShiftShiftLeftShift1
Right ShiftShiftRightShift2
Left Command / WindowsMetaLeftMeta1
SpacebarSpaceA space character (" ")0
Up arrowArrowUpArrowUp0

Read an event without misdiagnosing the keyboard

code
Useful for identifying a position across layout changes. KeyQ does not guarantee the typed character is Q.
key
Reflects modifiers and the active input layout. A combining accent can report Dead; this is unrelated to a physically broken key.
location
0 is standard, 1 is left, 2 is right, and 3 is the numeric keypad. Not every key has a left/right location.
repeat
True on an auto-repeating keydown. A held key repeating under OS settings is not automatically switch chatter.
ctrlKey / altKey / shiftKey / metaKey
Modifier state at the time of the event. AltGr interpretation varies by platform; use the resulting character as well.
timeStamp
The event creation timestamp, with browser precision restrictions. It is not the instant the physical switch closed.

Browser limitations

  • Fn usually changes firmware behavior without a standalone browser event.
  • System shortcuts, media controls and accessibility tools can intercept or transform input.
  • Focus changes can hide a keyup. Held-key state is cleared when focus is lost.
  • Virtual keyboards and IME composition may not emit the same key sequence as physical keyboards.
  • keyCode is deprecated. It is displayed only for comparison with older software.

A reproducible diagnostic flow

  1. Press one key in the keyboard test and record its code and key locally.
  2. If the code arrives but the character is wrong, compare the input layout and remapping settings.
  3. If no event arrives, try another app and browser with the same connection before following the missing-key workflow.
  4. If only a combination fails, compare the ghosting test and rollover test.

References and methodology

Maintained by Keyboardtest. Updated . How we test and review guidance.