Map Extract
Free tool

JavaScript key code finder

Press a key and see exactly what the browser reports for it: the character or name in event.key, the physical key in event.code, the old numeric keyCode, whether it was on the left, right or number pad, and which modifiers were held.

Runs in your browser. Nothing you enter is uploaded.

Finding a key's values

  1. Click the dark panel

    Keys are read only while the panel has focus, so click it or move to it with Tab. The rest of the page keeps its normal keyboard behaviour, and Esc leaves the panel.

  2. Press the key or combination

    The large panel shows the key, with its code and keyCode underneath. Hold Shift, Ctrl, Alt or the Windows or Command key at the same time to capture a combination.

  3. Read the table

    event.key, event.code, event.keyCode (deprecated), event.location (standard, left, right or numpad) and Modifiers held.

  4. Copy what you need

    Each value has its own copy button, ready to paste into a script, a shortcut setting or a support ticket.

Example: a shortcut that only works on one keyboard

A freelancer adds a keyboard shortcut to a client's internal order form: pressing the hash key opens a search box. It works on their UK keyboard but not on a colleague's US laptop. Pressing the key on each machine shows why: on a UK layout the hash key has its own key, reported with a code that differs from the US layout, where # is Shift and 3.

Matching on event.key (the character) rather than event.code (the physical position) makes the shortcut work on both layouts.

Input
Press: the # key on a UK keyboard
Result
event.key       "#"
event.code      "Backslash"
event.location  standard
Modifiers held  none

key, code and keyCode compared

PropertyWhat it tells youUse it for
event.keyThe character typed or the key's name, such as "a", "A", "Enter" or "ArrowLeft"Most shortcuts and text handling; follows the user's layout
event.codeThe physical key position, such as "KeyA" or "Digit3", whatever the layoutGames and controls where position matters more than the letter
event.keyCodeAn old numeric codeOnly for supporting very old code; it is deprecated
event.locationStandard, left, right or numpadTelling left Shift from right Shift, or numpad digits from the top row

Questions people ask

What is the keyCode for Enter?

Press Enter on this page to see it: event.key is "Enter", event.code is "Enter" for the main key or "NumpadEnter" for the number pad, and the legacy keyCode is 13. In new code, compare event.key with "Enter" rather than relying on the number.

Should I use event.key or event.code?

Use event.key when the meaning of the key matters, such as a letter, a symbol or Enter, because it follows the user's keyboard layout. Use event.code when the physical position matters, such as WASD controls in a game, which should stay in the same place on French or German keyboards.

Why is keyCode marked deprecated?

keyCode predates the modern keyboard standard and its numbers vary between browsers and layouts for many keys. Browsers still report it for compatibility, but the web standard recommends key and code instead. It is shown here for anyone maintaining older scripts.

Why does nothing happen when I press a key?

The tool only listens while its dark panel has focus, so that Tab, Space and the arrow keys still scroll and move around the page as usual. Click the panel, check that it shows a coloured outline, and press the key again.

Where your data goes

Key presses are read by this page and shown on screen only. Nothing you press is recorded, stored or sent to Map Extract or anywhere else.

Checked against the tool on

Top