JavaScript Key Code Finder
Press any key to see its JavaScript key, code and keyCode values.
| key | code | keyCode | which | location | modifiers |
|---|
What this tool does
JavaScript keyboard events report which key was pressed in three ways: event.key (the character or name, such as "Enter" or "a"), event.code (the physical key, such as "KeyA" or "Enter") and the deprecated event.keyCode number (13 for Enter). Click the box, press a key, and read all of them.
Listens for keydown in the box and shows every property of the event that matters.
Keeps a history and builds a code snippet.
How to use it
- Click the box so that it has focus.
- Press any key or key combination.
- Read key, code, keyCode, which, location and modifiers.
- Copy the JavaScript condition if you need it.
Why use this tool
Press any key and see event.key, event.code, the deprecated keyCode and which, the location (left, right, numpad) and the active modifiers, with a history of recent keys. Handling keyboard shortcuts in a web app requires the exact values, and they differ between key and code and between layouts. Testing the real key on your own keyboard avoids guesswork.
Why we built it
We built the key code finder to show event.key, event.code and the legacy keyCode together, because they differ between layouts. Test the hardware itself with the keyboard test and look up characters in the ASCII table.
Who this tool is for
- JavaScript developers writing shortcuts and game controls
- QA testers checking keyboards
- Students learning DOM events
When to use it
- Writing keyboard shortcuts and game controls.
- Debugging a keydown handler.
- Checking what a special key sends.
- Teaching keyboard events.
How it works
event.key is the value produced by the key given the layout and modifiers: "a", "A", "Enter", "ArrowUp". event.code identifies the physical key regardless of layout, so "KeyW" is the same key on QWERTY and AZERTY. keyCode and which are legacy numbers, still seen in old code but deprecated; prefer key or code in new code.
location tells left from right modifier keys and the numpad from the main keys. Browsers and operating systems reserve some combinations (such as Ctrl+W), which the page may never see.
What you give it, and what you get back
| Item | Details |
|---|---|
| Key press | Any key or combination while the box has focus. |
| Output | key, code, keyCode, which, location, modifiers, a history table and a code snippet. |
Issues you may run into
| What you see | Why it happens | What to do |
|---|---|---|
| Nothing happens | The box does not have focus. | Click inside the dashed box first. |
| A shortcut did not register | The browser or system keeps it. | Try a different key combination. |
| keyCode shows 229 | An input method editor is composing text. | Switch to a plain keyboard layout. |
Assumptions and limitations
- Shows keydown events only.
- Values depend on the keyboard layout and browser.
Frequently asked questions
What is the keycode for Enter?
13 (legacy keyCode), event.key "Enter" and event.code "Enter".
What is the difference between event.key and event.code?
key is the character the key produces; code is the physical key position.
Is keyCode deprecated?
Yes. Use event.key or event.code in new code.
Why does my numpad give different codes?
The numpad keys have their own codes, such as "Numpad1", and location 3.
Can it detect Ctrl and Shift?
Yes, modifiers are listed with each press.
Is anything sent to a server?
No. Everything runs in your browser and nothing leaves the page.