Keyboard key codes

Every key press gives a browser three different values. They mean different things, and only one of them is about the physical key.

Esc
F1
F2
F3
F4
F5
F6
F7
F8
F9
F10
F11
F12
` ~
1 !
2 @
3 #
4 $
5 %
6 ^
7 &
8 *
9 (
0 )
- _
= +
Backspace
Tab
Q
W
E
R
T
Y
U
I
O
P
[ {
] }
\ |
Caps
A
S
D
F
G
H
J
K
L
; :
' "
Enter
Shift
Z
X
C
V
B
N
M
, <
. >
/ ?
Shift
Ctrl
Win
Alt
Alt
Win
Menu
Ctrl
PrtSc
Scroll
Pause
Ins
Home
PgUp
Del
End
PgDn
Num
/
*
-
7
8
9
+
4
5
6
1
2
3
0
.

Press any key on your keyboard. Every key you press stays marked, so you can work across the board and see what is left.

untested

0 working

0 keys at once

Last key
press a key
Character
Key code
Held

The three values

The tester above shows all three for the last key you pressed, which makes the difference obvious. Press a letter, switch your operating system keyboard layout, and press the same key again: the code stays put and the character changes.

ValueWhat it describesExample pressing the same key
codeThe physical key position. Does not change with your language settings.KeyA
keyThe character produced, after the operating system layout is applied.a, or q on a French layout
keyCodeA legacy number kept for compatibility. Deprecated, but still widely used.65

Why code is the one you usually want

If you are checking hardware, the code is the honest value. It says which physical switch closed, regardless of what language the computer thinks it is in. A key that produces the wrong character but the right code is not broken.

If you are writing software, the same logic applies to anything positional. Game movement bound to the position of W, A, S and D should use the code, so the binding lands in the same physical place on a French AZERTY keyboard. Anything about the character the user meant to type should use the key value instead.

Common codes worth recognising

Left and right modifiers report separately, which is useful when testing: a keyboard where the left Shift works and the right does not will show that clearly.

KeysCodes
LettersKeyA to KeyZ
Digits along the topDigit0 to Digit9
Number pad digitsNumpad0 to Numpad9
Function rowF1 to F12
ModifiersShiftLeft, ShiftRight, ControlLeft, AltLeft, MetaLeft
ArrowsArrowUp, ArrowDown, ArrowLeft, ArrowRight
The ISO key beside left ShiftIntlBackslash

Keys a browser cannot see

The Fn key on a laptop is handled inside the keyboard controller and almost never reaches the operating system, so no web page can test it. Media keys, brightness keys and similar controls are often handled the same way.

Print Screen is usually captured by the operating system or a screenshot tool first. The Windows and Command keys frequently open a system menu instead of reaching the page. None of these silences mean a fault.

Why keyCode is deprecated but still everywhere

The numeric code predates both of the other values and was never well specified across browsers, which is exactly why it was replaced. It survives because an enormous amount of existing code reads it, and removing it would break those pages.

It is shown here because it is still the value many older tools and forum answers refer to, so having it on screen saves a lookup. For anything new, the physical position and the character are the two values worth using.

Repeat events

Holding a key down produces one initial event and then a stream of repeats generated by the operating system, not by the keyboard. Those repeats are marked as such, which is why the keys-at-once counter in the tester does not climb while you lean on a key.

The distinction matters when reading a chatter result. A repeat is the system doing its job at the interval your system settings specify. Chatter is a second genuine press arriving faster than a human could produce one, and the two are counted differently here for that reason.