JavaScript Keycode Info
Press a key and instantly read its event.key, event.code, keyCode and modifier flags — a live keyboard event inspector in your browser.
Updated
| key | code | keyCode |
|---|---|---|
| Enter | Enter | 13 |
| Escape | Escape | 27 |
| Space | Space | 32 |
| Tab | Tab | 9 |
| Backspace | Backspace | 8 |
| Delete | Delete | 46 |
| ArrowUp | ArrowUp | 38 |
| ArrowDown | ArrowDown | 40 |
| ArrowLeft | ArrowLeft | 37 |
| ArrowRight | ArrowRight | 39 |
| a | KeyA | 65 |
| 0 | Digit0 | 48 |
| F1 | F1 | 112 |
event.keyCode is deprecated — prefer event.code for physical keys and event.key for the produced character.
How to use JavaScript Keycode Info
The JavaScript Keycode Info tool is a live keyboard-event inspector. Focus the capture area, press any key, and it shows you the exact values your browser reports — event.key, event.code, the legacy event.keyCode, the physical key location and which modifier keys were held. It is the quickest way to find the right identifier when you are wiring up a keyboard shortcut, debugging a hotkey handler, or just curious what a particular key produces. A built-in reference table also lists the values for the most common keys, and everything runs locally so your keystrokes are never recorded or sent anywhere.
- Click the capture area so it has keyboard focus.
- Press the key or key combination you want to inspect.
- Read the reported event.key, event.code, keyCode and modifiers.
- Copy the details if you need them for your code.
- Use the reference table below for common keys without pressing them.
Your data never leaves your device — 100% private processing.
key vs code vs keyCode
Modern keyboard events expose three identifiers that are easy to confuse. event.key is the character or named value the key produces in the current layout and modifier state — pressing Shift+a gives "A", and a layout-aware key like AltGr can change it. event.code is the physical key on the keyboard, written as a stable name like "KeyA" or "Digit1" that does not change with layout, which makes it ideal for game controls and position-based shortcuts. event.keyCode is the old numeric code (65 for the A key) that predates both; it is deprecated, varies between browsers, and should be avoided in new code. Choosing the right one — code for physical position, key for the typed character — prevents most shortcut bugs.
| Property | Value | Use it for |
|---|---|---|
| event.key | a (or A with Shift) | The character actually typed |
| event.code | KeyA | The physical key, layout-independent |
| event.keyCode | 65 (deprecated) | Legacy code only — avoid in new code |
Modifier keys and key location
Each keyboard event also carries four boolean modifier flags — ctrlKey, altKey, shiftKey and metaKey (Command on macOS, Windows key on Windows) — which this tool summarises so you can see exactly which combination was pressed. The location value distinguishes otherwise-identical keys: a left Shift reports location “Left”, a right Shift reports “Right”, and number-pad keys report “Numpad”, which lets you treat the numeric keypad differently from the top-row digits. Knowing both the modifiers and the location is essential when you want a shortcut like Ctrl+Left-Shift to behave differently from Ctrl+Right-Shift, or when a Numpad Enter should do something distinct from the main Enter key.
Worked examples
Press Enter
Inputs: Enter key
Result: key: Enter · code: Enter · keyCode: 13
Press Shift+A
Inputs: Shift + a
Result: key: A · code: KeyA · modifiers: Shift
Glossary
- event.key
- The DOM property holding the character or named value a key produces, accounting for layout and modifiers.
- event.code
- The DOM property naming the physical key pressed, independent of keyboard layout.
- keyCode
- A deprecated numeric key identifier kept only for backward compatibility with older code.
- Modifier key
- A key such as Ctrl, Alt, Shift or Meta that changes the meaning of another key when held.
- Key location
- A value indicating where a key sits — standard, left, right or numpad — used to tell duplicate keys apart.
Related reading
Frequently Asked Questions
Get weekly tool tips & updates
New tools, power-user tips, and productivity hacks — delivered free every Friday.
No spam, ever. Unsubscribe with one click.
Why use JavaScript Keycode Info?
- See event.key, event.code and keyCode for any key in real time
- Identify modifier combinations (Ctrl, Alt, Shift, Meta) at a glance
- Distinguish physical keys from produced characters across layouts
- Includes a quick-reference table of common keys and codes
- Captures keys locally — keystrokes are never logged or uploaded
Common use cases
- Find the correct event.code when building a keyboard shortcut
- Debug why a hotkey handler is not firing for a specific key
- Compare key values between different keyboard layouts
- Teach how the DOM keyboard event model works
- Look up the deprecated keyCode for legacy code you are maintaining
Related Developer Tools
Unicode Escape / Unescape
Escape text to Unicode sequences (\uXXXX, HTML &#x; entities, CSS \HH) or unescape them back to readable characters. Free, instant, in your browser.
HTML Encoder / Decoder
Encode and decode HTML entities online. Escape <, >, &, and quote characters for safe HTML display. Free, instant, and private — runs in your browser.
URL Encoder / Decoder
Encode and decode URLs and URL components online. Convert special characters to percent-encoding and back instantly — free, private, and fast.
JSON Formatter & Validator
Format, validate, and minify JSON instantly. Includes syntax highlighting, error detection, and a collapsible tree view — free, private, in-browser.
Regex Tester
Test and debug regular expressions online. See live matches, capture groups, and replace output. Free, private, instant.
Base64 Encoder & Decoder
Encode text or files to Base64, or decode Base64 strings back to text. Fast, free, and runs entirely in your browser.
Explore all Developer Tools.