Home › Developer Tools › Keyboard Key Code Finder

Keyboard Key Code Finder

Press any key in the box below to see its KeyboardEvent key, code, location and modifiers, with a plain-English name for the key.

Press any key here

The box takes the Tab key, so Tab does not move focus out of it. Click anywhere else to leave the box.

No key pressed yet.
key-
code-
location-
Modifiers held-
Plain name-

How to use

  1. Click the box that says "Press any key here" so it has focus.
  2. Press a key. The result line and the five figures below update on every keydown.
  3. Hold Shift, Control, Alt or Meta while you press another key to see the Modifiers held figure change.
  4. Press the same key on the left and right side of the keyboard, or on the number pad, and compare the location figure.
  5. Click anywhere outside the box to hand focus back to the page. Tab is captured by the box, so it will not move focus out.

Worked example

Hold Shift and press the A key. The page reports key A (capital), code KeyA, location standard, modifiers Shift and the plain name "Letter A". Release Shift and press it again: key becomes a, while code stays KeyA. The first value follows the character produced, the second follows the physical key.

Now press 1 on the number pad. You get key 1, code Numpad1, location numpad and the name "Numpad 1". The same key value on the top row would give code Digit1 and location standard. The space bar reports key as a single space character and code Space.

How it works

The key is read in your browser, from the keydown event that the browser fires for the box. Nothing is sent or stored, and the page only reads keys pressed in the box. Keys pressed anywhere else are not read.

key is the character or key name after modifiers, so Shift turns a into A. code is the physical key, and it stays the same on every keyboard layout. location tells you whether a key is on the left or right side of the keyboard, or on the numpad.

keyCode and which are deprecated in the web standard, so this page does not use them. Source: MDN KeyboardEvent documentation.

The properties are defined by the W3C UI Events specification, with the code values listed in UI Events KeyboardEvent code Values. The MDN pages for KeyboardEvent.key and KeyboardEvent.code list the values in a readable form.

Which property to use in your code

GoalUseWhy
React to a typed character or a named key such as EnterkeyIt follows the user's layout and modifiers.
Game controls such as WASDcodeThe physical position stays the same on AZERTY or Dvorak layouts.
Tell left Shift from right Shiftcode or locationkey reports only "Shift" for both.
Detect Ctrl, Alt, Metathe modifier flagsThey are set on every key event while held.

Common mistakes

Frequently asked questions

Why does a key show "Unidentified"?

Some keys, often media or special function keys, have no standard value, so the browser reports Unidentified for key.

Why are the codes the same on every keyboard layout?

The code names a physical position on a US-style layout, so KeyQ is always the key to the right of Tab, whatever is printed on it.

Does the page record what I type?

No. It reads keydown events in the box to fill the figures and keeps nothing.

Why does the Tab key not leave the box?

The box captures Tab so you can see its values. Click elsewhere to leave.

Are keypress and keyup supported?

The page reads keydown only. For most uses the values are the same on keyup.

Related tools