Keycode Info
Press any key to see its JavaScript keyCode, key, code, which, and location event properties.
Keycode Info tool
Example
Input: Press the Enter key
Result: event.key: Enter, event.code: Enter, event.keyCode: 13, event.which: 13, event.location: Standard
key is the character or key name, code is the physical key position, and keyCode and which are the legacy numeric codes still used by older scripts.
- Open the tool page (on a phone or tablet, tap the input field to bring up the on-screen keyboard).
- Press any key to see its event properties.
- Read the key, code, keyCode, which and location values.
- Hold Ctrl, Shift, Alt or Meta while pressing another key to see the modifier states change.
- Copy the key value, or copy the keydown snippet for your event handler.
JavaScript Key Events: key, code and keyCode
Press any key and this tool shows what JavaScript sees. You get event.key, event.code, the older keyCode and which values, the key location, and whether Ctrl, Shift, Alt or Meta was held down. Press Enter, for example, and you get key "Enter", code "Enter" and keyCode 13.
The two modern properties answer different questions. event.key is the character or name the key produces, so it changes with the keyboard layout and with Shift. The same key can give "a", "A", or "q" on a French keyboard. event.code is the physical key position, such as KeyA or Digit1, and it stays the same whatever the layout. Use key for typed text, and code for game controls or shortcuts tied to a spot on the keyboard.
keyCode and which are older numeric codes. They are deprecated, which means browsers keep them only so old code still works. Their values can differ between browsers and layouts, so new code should avoid them. The location value tells left and right keys apart, like the two Shift keys, and marks keys on the number pad.
The tool also shows the event type, the repeat flag (true while a key is held down) and the character code of printable keys. It writes a keydown snippet for the key you pressed, with any modifiers, ready to copy. Arrow keys, the space bar and page keys are caught so the page does not scroll while you test.
On a phone or tablet, tap the input box to open the on-screen keyboard. Many mobile keyboards report key "Unidentified" and keyCode 229 while they build a word, which is normal. To look up the code point of any character, use Text to Unicode.
Sources
Frequently Asked Questions
Related Tools
Regex Tester
Test regular expressions with real-time match highlighting, group capture display, and a pattern library.
Developer ToolsHTML Entity Encode and Decode
Convert special characters to HTML entities and decode HTML entities back to readable text.
Developer ToolsText to Unicode Converter
Convert text to Unicode code points and back. Supports U+XXXX, HTML hex, HTML decimal, and 0x hex formats.
Text and Writing