Keyboard Key Code Finder
Click inside the capture area and press any key to instantly see every JavaScript keyboard event property: event.key, event.code, keyCode, which, charCode, and the active modifier keys. All processing happens in your browser — no keystrokes leave your device.
event.key vs. event.code
These two properties look similar but serve different purposes:
| Property | What it returns | Layout-aware? |
|---|---|---|
event.key | The printed character or key name as typed | Yes — Shift+a gives “A” |
event.code | The physical key position on the keyboard | No — always “KeyA” for the A key |
Use event.key when you care about what character the user typed. Use event.code when you care about which physical key was pressed regardless of modifiers or keyboard layout — for example, game controls that should work the same on AZERTY and QWERTY keyboards.
Deprecated Properties
Three properties shown by this tool are marked deprecated by the W3C and should not be used in new code:
keyCode— A numeric code originally defined per browser, without a consistent standard. Different browsers assigned different values for non-alphanumeric keys.which— Similar tokeyCode, also non-standard and inconsistent.charCode— Intended for character keys only; always 0 for non-printable keys.
Modern code should use event.key and event.code instead. These deprecated properties are shown for compatibility reference when working with older codebases.
Location Values
The location property distinguishes keys that appear more than once on the keyboard:
| Value | Meaning |
|---|---|
0 | Standard (most keys) |
1 | Left side (Left Shift, Left Ctrl, Left Alt) |
2 | Right side (Right Shift, Right Ctrl, Right Alt) |
3 | Numpad |
Common Use Cases
Detecting key combinations: Use event.code combined with event.ctrlKey, event.shiftKey, event.altKey, and event.metaKey to build keyboard shortcuts that work independently of the user’s keyboard layout.
Text input handling: Use event.key to check what character was entered. For example, event.key === 'Enter' reliably detects the Enter key regardless of platform or layout.
Game controls: Map physical positions (e.g. WASD) using event.code so the controls remain in the same place on all keyboard layouts.