JavaScript KeyCode Finder & Event Reference
Instantly find the numeric keyCode, key, and code values for any keyboard press. Our interactive JS KeyCode tool helps developers capture user input, build keyboard shortcuts, and handle game controls with precision. Just press a key to see the event data in real-time.
In web development, handling keyboard events is essential for accessibility and user experience. This tool provides the three critical values you need for addEventListener:
- event.key: The actual character produced (e.g.,
"a", "Enter", "ArrowUp").
- event.code: The physical key on the keyboard (e.g.,
"KeyA", "NumpadEnter").
- event.keyCode (Legacy): The numeric code associated with the key (e.g.,
13 for Enter, 27 for Escape).
Modern vs. Legacy Key Events
While many older tutorials use event.keyCode, the modern web standard has shifted toward event.key and event.code for better cross-browser and international keyboard support.
- Deprecated:
keyCode, which, and charCode.
- Modern Standard:
key (value-based) and code (location-based).
Common JavaScript KeyCodes Reference
| Key |
keyCode |
.key Value |
.code Value |
| Enter |
13 |
"Enter" |
"Enter" |
| Escape |
27 |
"Escape" |
"Escape" |
| Space |
32 |
" " |
"Space" |
| Arrow Up |
38 |
"ArrowUp" |
"ArrowUp" |
| Tab |
9 |
"Tab" |
"Tab" |
How to Use the KeyCode Finder
- Focus: Click on input on this page to ensure it is active.
- Press: Hit any key on your keyboard.
- Inspect: The screen will instantly update with the numeric code and the string values for that specific event.
- Implement: Copy the values directly into your
if statements or switch cases.
Developer Note: All event detection happens locally in your browser via a keydown listener. No data is logged or sent to our servers.