Keyboard Key Code Viewer
Press any key to get the JavaScript Event KeyCode
Event Properties
Recent History
Recommended Tools
Hand-picked utilities you might find useful
Finding the JavaScript Key Code for Any Key
Overview
When you build keyboard interactions on the web, you need to know exactly what value a key press produces — its `key`, `code`, and legacy `keyCode`. A key code viewer shows these live: press any key and it displays the identifiers your JavaScript will see. This tool captures key events in your browser so you can wire up shortcuts and handlers without guessing.
How to Use (Step by Step)
- 1
Focus the tool and press a key
Click into the viewer and press any key or combination you want to inspect.
- 2
Read the identifiers
See the `key`, `code`, `keyCode`, and which modifiers were held.
- 3
Use the right property
Copy the value that fits your handler — usually `key` for characters, `code` for physical key positions.
How It Works
The tool listens for keyboard events and, when you press a key, reads the event's properties: `key` (the character or name, like 'a' or 'Enter'), `code` (the physical key, like 'KeyA'), the numeric `keyCode` (deprecated but still seen), and modifier states (Shift, Ctrl, Alt, Meta). It shows them instantly. Everything runs locally in your browser — no keystrokes are logged or sent anywhere.
When to Use This
Building a keyboard shortcut and needing the exact `key` or `code` to match. Debugging why a handler doesn't fire for a certain key. Telling apart keys that share a character across layouts. Detecting modifier combinations for a shortcut. Learning the difference between `key`, `code`, and `keyCode`. Verifying what a special or media key reports.
Frequently Asked Questions
`key` is the produced value, affected by layout and modifiers (Shift+a gives 'A'). `code` is the physical key position, unaffected by layout (always 'KeyA' for that key). Use `key` for characters, `code` for physical-position shortcuts like WASD.
Important Notes
Some keys behave differently across browsers, operating systems, and keyboard layouts — dead keys, IME input, and media keys especially. Test on your target platforms rather than assuming one machine's values apply everywhere.