Skip to content

JavaScript Keycode Tester

Press any key and see event.key, event.code and the modifier state.

—

Click here, then press any key

Quick Tool Overview

The Keycode Tester shows every property of a keyboard event at once — key, code, the deprecated keyCode, location and the modifier flags — so the difference between what was typed and which key was pressed is visible rather than theoretical.

What it does
Reports every property of a key event
You give it
A key press
You get back
key, code, keyCode, location and modifiers
Best for
Building keyboard shortcuts and game controls
Developer Tools Free, unlimited use No sign-up Runs in your browser

About the JavaScript Keycode Tester

Press any key and every property of the event is shown at once: event.key, event.code, the deprecated keyCode and which, the location, the modifier flags and whether the browser considers it a repeat.

Seeing key and code side by side is the point, because they answer different questions. event.key is the character produced, so it changes with the keyboard layout and with Shift — on a French layout the key above Tab gives a different key. event.code is the physical position, so it stays KeyW wherever the keyboard is from, which is why games use it and text input does not. Choosing the wrong one is how a shortcut works for you and not for someone in another country.

Key features of the JavaScript Keycode Tester

key and code side by side

One is the character produced and changes with layout and Shift; the other is the physical position and does not. Seeing both is the whole point.

Modifier state shown

Ctrl, Shift, Alt and Meta flags, which matters because Mac users press Command where Windows users press Control.

Location reported

The only way to distinguish left Shift from right, or the number pad from the number row.

Guidance, not just values

Which property to use for which job, so a shortcut works on a keyboard from another country.

Legacy values included

keyCode and which are shown for reading older code, alongside a note that neither belongs in new code.

How to use the JavaScript Keycode Tester

  1. 1

    Click the page and press a key

    Any key, including modifiers and function keys.

  2. 2

    Compare key and code

    One is the character produced, the other is the physical position.

  3. 3

    Try it with Shift

    key changes, code does not — which is the whole distinction.

  4. 4

    Copy what you need

    Click any value to copy it into a comparison in your code.

Frequently asked questions

event.key for anything about what the user typed — a shortcut like Ctrl+S, or checking for Enter and Escape. event.code for physical position, such as WASD in a game, where the letter printed on the key does not matter.

Reviews of the JavaScript Keycode Tester

What people who use the JavaScript Keycode Tester think of it. Reviews come from visitors and are posted as written.

No ratings yet

Yours would be the first.

  • 5 0 reviews rated 5 stars
  • 4 0 reviews rated 4 stars
  • 3 0 reviews rated 3 stars
  • 2 0 reviews rated 2 stars
  • 1 0 reviews rated 1 star

Write a review

Used this tool? Your rating helps the next person decide.

Your rating

Plain text only — links, email addresses and HTML are not accepted. Your name and review are shown publicly; nothing else is collected. See the privacy policy.

0 reviews

Newest first

No reviews yet

Be the first to rate the JavaScript Keycode Tester. It takes half a minute and no account.

Write the first review

More developer tools