Keycode info
Find the javascript keycode, code, location and modifiers of any pressed key.
About Keycode info
Press any key and see what JavaScript reports for it: the key value, the legacy keyCode number, the physical code, the location (left or right Shift, numpad) and which modifiers were held.
When you would use it
- Finding the right value to compare against in a keydown handler or a keyboard shortcut library.
- Debugging why a shortcut works on one keyboard layout and not another.
- Checking what a special key (media keys, Fn combinations, dead keys) sends to the page.
How to use it
- Click on the page so it has focus, then press a key.
- Read the values; each field has a copy button.
- Hold modifiers (Shift, Ctrl, Alt, Meta) to see them reported.
Things worth knowing
- key is the character or name produced (a, A, Enter, ArrowLeft) and depends on the layout and modifiers; code is the physical position (KeyA, Digit1, NumpadEnter) and does not. Use code for game-style controls, key for typing-oriented shortcuts.
- keyCode is deprecated and inconsistent across browsers and layouts (and 0 for many keys). It is shown for legacy code only; new code should use key or code.
- Some keys never reach the page: the browser or operating system handles them first (Cmd+Q, Alt+Tab, some function keys, Print Screen).
- On macOS the Meta key is Cmd; on Windows it is the Windows key. AltGraph appears on European layouts for the right Alt key.
Frequently asked questions
- Why does the key show Dead or Unidentified?
- Dead means a dead key (such as ยด or ^) waiting to combine with the next letter. Unidentified means the browser has no name for that key, common for some laptop-specific or media keys.
- Why is keyCode 0 or the same for different keys?
- keyCode was never standardised. Browsers report 0 for keys they cannot map, and some keys share codes. That is exactly why key and code replaced it.