Keycode (e.code / e.key) Checker
Click the box below to focus it, then press any key to see its event.key, event.code, keyCode, location, and modifier key state in real time. Handy for checking real-device values while implementing keyboard event handling in JavaScript, or for understanding the difference between event.key and event.code. Everything happens in your browser, and the keys you press are never sent to a server. If you also need to test input patterns, try the Regex Tester as well.
🔒 Runs in your browser · Your data is never sent to a server
Click here to focus, then press any key
History (last 10)
Notes
- To detect a key press, click the box above to focus it first, then press any key.
- While the box is focused, browser default actions such as Tab moving focus or F5 reloading the page are prevented so you can see their values (clicking outside the box, or pressing Escape, restores normal behavior).
- Keys pressed while an IME is mid-conversion may report a special event.key value such as "Process", depending on your environment.
- The same physical key can report a different event.key value depending on keyboard layout (e.g. JIS vs. US). event.code represents the physical position and does not depend on layout.
- Some keys, such as media keys or shortcuts reserved by the browser, may not be detectable depending on your browser and OS combination.
Glossary
event.key
The character or function name a pressed key represents (e.g. "a", "Enter", "ArrowUp"). Its value can change depending on keyboard layout, whether Shift is held, or whether an IME is mid-conversion.
event.code
A string representing the physical location of a key on the keyboard (e.g. "KeyA", "Digit1"). Pressing the "1" key gives event.key a value of "1" or "!" depending on Shift, but event.code always stays "Digit1" regardless of keyboard layout.
KeyboardEvent.location
Distinguishes keys that appear more than once on a keyboard, such as Shift, Ctrl, Alt, and Enter. 0 means standard, 1 means left, 2 means right, and 3 means the numeric keypad.
keyCode / which (deprecated)
Older browser APIs that represent a key as a number. Their interpretation varies across browsers and keyboard layouts, so they are deprecated — new code should use event.key or event.code instead.
Modifier key
A general term for keys such as Ctrl, Alt, Shift, and Meta that are held down together with another key. The Meta key corresponds to the Windows key on Windows and the Command key on Mac.
FAQ
What is the difference between event.key and event.code?
event.key is the meaning of the key press (for example "a") and changes with layout and modifiers. event.code is the physical key position (for example "KeyA") and is layout-independent, which suits game controls.
Should I still use keyCode?
keyCode is deprecated. Use event.key or event.code in new code. The tool shows it only to help with checking legacy code.
Why does a key pressed during IME input show "Process"?
While an IME is composing, event.key can become a special value such as "Process". Focus the input area and turn the IME off to see the raw key.
Share this page
