Free online keyboard event inspector that displays event.key, event.code, keyCode, modifiers, and location in real time. Press any key and get a ready-to-use JavaScript event listener code snippet instantly.
Keyboard Event Viewer is a free, browser-based tool
from UseToolSuite's
String & Text Tools collection.
All processing happens locally on your device — your data is never uploaded to any server.
Use the tool below, then scroll down for detailed documentation, frequently asked questions, and related resources.
What is Keyboard Event Viewer?
Keyboard Event Viewer is a free online tool that displays all JavaScript keyboard event properties in real time as you press keys. It shows event.key, event.code, event.keyCode, event.which, modifier states, key location, and repeat status — everything you need when building keyboard shortcuts, accessibility features, or game controls. It also generates a ready-to-use JavaScript event listener code snippet for the key you pressed and maintains a scrollable event log. All processing happens locally in your browser.
When to use it?
Use the Keyboard Event Viewer when you need to look up the exact event.key or event.code value for a specific key, debug keyboard shortcuts across different keyboard layouts, check whether the deprecated keyCode property matches your expectations, or understand the difference between left and right modifier keys using event.location. It is especially useful when building keyboard-driven interfaces where you need to know the precise event properties before writing your handler code.
Common use cases
Developers use the Keyboard Event Viewer to debug hotkey implementations in web apps, verify that arrow keys and function keys produce the expected event codes, test modifier key combinations (Ctrl+Shift+S, Cmd+K) for custom shortcuts, check keyboard behavior in accessibility testing, understand key repeat behavior for game-like interactions, and generate boilerplate JavaScript code for event listeners. It is also a valuable reference tool for understanding the differences between the modern event.key/event.code API and the deprecated event.keyCode/event.which properties.
key vs code vs keyCode — the three identities of a keypress
Press one key and the event carries several different descriptions of it. Knowing which to read is most of the battle:
| Property | Tells you | Layout-dependent? | Status |
|---|
event.key | The character/value produced ("a", "A", "Enter") | Yes | Use this |
event.code | The physical key position ("KeyA", "Space") | No | Use this |
event.keyCode | Legacy numeric code | Yes | Deprecated |
keyCode is deprecated and shouldn’t be used in new code, but it’s still shown here for maintaining legacy systems. For everything new, it’s key (what was typed) and code (which physical key) — and the FAQ above explains which to pick.
Detecting combinations
A shortcut like Ctrl+Shift+S is just a key/code check combined with the modifier booleans the event always carries: event.ctrlKey, event.shiftKey, event.altKey, and event.metaKey (Command on macOS, Windows key on Windows). This viewer generates the exact condition for whatever combination you press, including the cross-platform nuance that “Ctrl” on Windows is often “Cmd” (metaKey) on macOS — a detail that trips up a lot of shortcut code.
Why some keys never reach your handler
If a key seems “dead,” it may be intercepted before JavaScript sees it. PrintScreen is grabbed by the OS, F11 toggles browser fullscreen, and Ctrl+W closes the tab — and preventDefault() can’t always override these reserved combinations. When designing shortcuts, prefer combinations (Ctrl+Shift+letter) that browsers don’t already claim, and test on the platforms you support, since the reserved set differs between OSes and browsers.
The focus gotcha
Key events fire on the focused element first. A document-level listener may not behave as expected when an <input>, <textarea>, or contenteditable has focus and consumes the event. For global shortcuts, check event.target.tagName to decide whether to act or defer, or attach the listener with { capture: true } to see the event on the way down. Combined with the isComposing guard above, that’s the recipe for shortcuts that don’t fight with text entry.
How helpful was this tool?
Click to rate
Awesome! Glad it helped.
We don't have a marketing budget. The best way to support this free tool is by sharing it with other developers!
Help us improve!
Sorry it didn't meet your expectations. We're always looking to make these tools better. What was missing or broken?
Open GitHub Issue