Skip to main content
tetono.

Keyboard Keycode Tester

Press any key and see exactly what JavaScript receives — key, code, keyCode and which

Press any key to start

No need to click a field first — just type

Everything runs in your browser — nothing you press is logged or sent anywhere.

About this tool

The JavaScript keycode tester shows you exactly what your code receives when someone presses a key. Press a key and this page displays event.key, event.code, keyCode and which together — no console, no throwaway test script.

Building keyboard shortcuts, game controls, or handling Enter and Escape in a form goes wrong most often for one reason: the four values mean different things and it is easy to pick the wrong one.

  • event.key — the character the key types; changes with layout and with Shift
  • event.code — the physical key position; stable across layouts, right for shortcuts and games
  • keyCode — the legacy number, deprecated but still all over existing code
  • event.location — whether it was the left key, the right key or the numeric keypad

The page also reports the modifiers held (Ctrl / Alt / Shift / Command), the character's Unicode code point, and a history of recent presses so you can compare several keys in a row. One button copies the whole set as JSON.

Everything runs in your browser. Free, no sign-up, and nothing you press leaves the page.

How to use

  1. 1Open this page and press any key — you don't need to click a field first
  2. 2Read the event.key, event.code, keyCode and which values shown instantly
  3. 3Hold Ctrl, Shift, Alt or Command to see how the modifier values change
  4. 4Hit copy to take the whole set as JSON straight into your code

Frequently asked questions

What is the difference between event.key and event.code?
event.key is the character the key produces, which changes with the keyboard layout and with Shift — the same physical key can give a, A or ฟ. event.code is the name of the physical key position, e.g. KeyA, and it does not change when the layout changes. For shortcuts and game controls, use event.code.
Can I still use keyCode?
It still works in current browsers, but the standard marks it deprecated and a few keys report different numbers across browsers. New code should use event.key or event.code — but when you are maintaining older code that checks keyCode, this tool gives you the right number.
Why does nothing happen for some keys?
Some keys are captured by the browser or the operating system before the page ever sees them — F5 (reload), F12 (developer tools) or Ctrl/Command + W (close tab). This page shows a note when it detects one of those.
What is event.location for?
It tells you which of several same-named keys was pressed: 0 is a standard key, 1 is the left-hand one, 2 the right-hand one and 3 the numeric keypad. That is how you tell left Shift from right Shift.
Are my keystrokes sent anywhere?
No. Everything is read and displayed in your browser only — nothing you press is logged or transmitted.

Related tools

Regex Tester

Test regular expressions and see matches.

JSON Formatter

Format, validate and minify JSON — for developers.

UUID Generator

Generate random UUID v4s, with copy.

HTML Entity Encode / Decode

Encode and decode HTML entities and special characters.