JavaScript KeyCode & Key Event Reference
Press any key to see its event properties. Browse all key codes in the searchable reference table.
About This Tool
The JavaScript KeyCode & Key Event Reference is a free,
browser-based tool that helps developers quickly look up keyboard
event properties. When you press a key in the interactive area
above, the tool captures the native
KeyboardEvent and displays every property you might
need: event.key, event.code,
event.keyCode, event.which, modifier
states (ctrlKey, shiftKey,
altKey, metaKey), and the key's
physical location (standard, left, right, or numpad).
Handling keyboard input correctly is one of the most common
challenges in front-end development. The legacy
keyCode and which properties were once
the only reliable way to identify keys, but they behave
inconsistently across browsers and keyboard layouts. The modern
event.key property returns a human-readable string
like "Enter" or
"ArrowUp", while
event.code identifies the physical key regardless of
which character it produces. This tool shows all three
representations side by side so you can pick the right one for
your use case.
The searchable reference table below lists every standard key with
its name, event.key value,
event.code value, and legacy keyCode
number. You can filter by category (letters, numbers, function
keys, navigation, modifiers, punctuation, or special keys) and
use the search bar to jump to any key instantly. When you press a
key in the interactive area, the matching row in the table is
highlighted for quick cross-reference.
All processing happens entirely in your browser. No keystrokes are recorded, transmitted, or stored on any server. This makes the tool safe to use in any environment, including when testing keyboard shortcuts that involve sensitive modifier combinations.
How to Use
- Click the Press Any Key area at the top to give it keyboard focus.
- Press any key on your keyboard. The tool instantly displays
event.key,event.code,keyCode,which, modifier states, and the key location. - Click the copy button next to any value to copy it to your clipboard.
- Scroll down to the Reference Table to browse all available key codes.
- Use the search bar to filter by key name, event value, keyCode number, or description.
- Switch category tabs (Letters, Numbers, Function, Navigation, Modifiers, Punctuation, Special) to narrow the table.
- The table row matching your last pressed key is automatically highlighted for easy identification.
FAQ
What is the difference between event.key and event.code?
event.key returns the character or function associated with the key press, taking into account modifiers and keyboard layout (e.g., pressing Shift+1 gives "!"). event.code identifies the physical key on the keyboard regardless of layout or modifiers (e.g., "Digit1" is always the same physical key, whether you type "1" or "!").
Is event.keyCode deprecated?
Yes. Both event.keyCode and event.which are deprecated in the UI Events specification. They remain supported in browsers for backward compatibility and are still widely searched by developers. For new code, use event.key or event.code instead.
Why do some keys not trigger an event?
Certain keys and key combinations are intercepted by the operating system or browser before they reach the page. For example, Cmd+Q on macOS quits the browser, and Ctrl+W closes the tab. Print Screen may also be captured by the OS. These events cannot be reliably detected in web applications.
What does the location property mean?
event.location indicates where on the keyboard a key is located. The value 0 (Standard) means a general key, 1 (Left) and 2 (Right) distinguish between duplicate keys like left and right Shift, and 3 (Numpad) identifies number pad keys.
Is my data safe?
Absolutely. This tool runs entirely in your browser. No keystrokes are recorded, sent to a server, or stored anywhere. You can verify this by checking the Network tab in your browser's DevTools while using the tool.
Should I use keydown, keyup, or keypress?
Use keydown for most use cases, as it fires for all keys including modifiers and function keys. The keypress event is deprecated and no longer fires in modern browsers for non-printable keys. Use keyup only when you specifically need to know when a key is released.
Why are keyCode values different on different keyboards?
The legacy keyCode values can vary between keyboard layouts and operating systems, which is one reason they were deprecated. For example, the semicolon key may report different codes on US vs. European layouts. This inconsistency is why the W3C recommends using event.key (for the character produced) or event.code (for the physical key) in modern applications.
Related Tools
ASCII / Unicode Table
Browse, search, and filter ASCII and Unicode characters with decimal, hex, octal, and binary values.
HTTP Status Codes
Browse, search, and learn about all HTTP status codes with detailed explanations.
HTML Entity Encode/Decode
Encode and decode HTML entities, named characters, and Unicode escape sequences.
String Escape/Unescape
Escape and unescape strings for JSON, JavaScript, HTML, URL, SQL, and CSV formats.