How to use the JavaScript Keycode Finder
- Click anywhere on the page and press a key.
- Read
event.key,event.code,keyCodeand the other values in the boxes. - Copy the snippet to handle that key in your own code.
- Recent keys are listed underneath, so you can compare them.
key, code or keyCode?
event.keyis the character or name the key produces, like"a","A","Enter"or"ArrowLeft". It follows the keyboard layout and Shift. Use it for shortcuts and text.event.codeis the physical key, like"KeyA"or"Digit1", whatever the layout. Use it for game controls such as WASD, so they work on AZERTY keyboards too.event.keyCodeandwhichare old numeric codes. They're deprecated, but still found in older code, so they're shown for reference.
Common key codes
| Key | event.key | event.code | keyCode |
|---|---|---|---|
| Enter | Enter | Enter | 13 |
| Escape | Escape | Escape | 27 |
| Space | " " | Space | 32 |
| Tab | Tab | Tab | 9 |
| Backspace | Backspace | Backspace | 8 |
| Delete | Delete | Delete | 46 |
| ← ↑ → ↓ | ArrowLeft, ArrowUp, ArrowRight, ArrowDown | same | 37, 38, 39, 40 |
| Shift / Ctrl / Alt | Shift, Control, Alt | ShiftLeft, ControlLeft, AltLeft… | 16, 17, 18 |
| A–Z | a–z (A–Z with Shift) | KeyA–KeyZ | 65–90 |
| 0–9 | 0–9 | Digit0–Digit9 | 48–57 |
| F1–F12 | F1–F12 | F1–F12 | 112–123 |
To check that every key on your keyboard works, try the keyboard tester on our sister site.
Frequently asked questions
What is the keycode for Enter?
13. Its event.key and event.code are both "Enter".
Should I still use keyCode?
No. It's deprecated. Use event.key for characters and shortcuts, and event.code for physical positions.
Why don't some keys show up?
The operating system or browser can take some shortcuts first, like Ctrl+W, the Windows key or Print Screen, before the page sees them.
Updated