JavaScript Keycode Viewer.
Press any key to see event.key, event.code, keyCode, location and modifiers, with a ready keydown handler.
Runs in your browser| key | code | keyCode | location | modifiers |
|---|
About JavaScript Keycode Viewer
The JavaScript Keycode Viewer shows exactly what the browser reports when you press a key. Focus the page and press anything, a letter, an arrow, a function key or a shortcut such as Cmd+K, and you see event.key (the character or key name the user meant, like "k", "Enter" or "ArrowUp"), event.code (the physical key position, like KeyK or Numpad7), the deprecated keyCode and which numbers that old code still checks, event.location (left, right or numpad), the modifier keys held and whether the event is an auto-repeat. A history of recent presses makes it easy to compare keys, for example the left and right Shift or the two Enter keys. For each key the tool writes a keydown handler with the right condition, such as event.key === 'k' && event.metaKey for a command palette shortcut. Use event.key for shortcuts tied to a letter and event.code for game controls that should stay in the same place on AZERTY or Dvorak keyboards. Common mistakes are comparing keyCode, which differs between layouts and browsers, listening to keypress, which is deprecated and misses non-character keys, and forgetting that Shift changes event.key from "a" to "A". Some combinations are reserved by the operating system and never reach the page. Nothing is recorded or sent: the viewer runs in your browser.
How to Use
- Click the capture area and press any key or shortcut.
- Read event.key, event.code, keyCode, location and modifiers.
- Copy the generated keydown handler.
Frequently Asked Questions
Should I use event.key or event.code?
event.key for shortcuts that refer to a character (Ctrl+S) and event.code when the physical position matters (WASD in games), because code ignores the keyboard layout.
Is keyCode still safe to use?
It still works but is deprecated and inconsistent across layouts. New code should use key or code.
Why does a shortcut not show up?
The operating system or browser handles some combinations (Cmd+Tab, Ctrl+Alt+Delete, Cmd+W) before the page receives them.
Are my keystrokes recorded?
No. They are only shown on this page and are never stored or sent anywhere.
Related Tools
See your live viewport size, screen resolution, pixel ratio, active CSS breakpoints and media features.
Encode and decode URL components.
Encode and decode HTML entities.
Escape and unescape strings for different formats.
Drag the handles of a CSS cubic-bezier easing curve, preview the motion and copy the timing function.
Set each corner radius, including elliptical corners, and copy the shortest CSS or Tailwind classes.