JavaScript Keycode Finder

Press any key to instantly see its JavaScript event.key, event.code, keyCode, and which values.

?
Press any key on your keyboard
event.key
-
event.code
-
event.keyCode
-
event.which
-
Shift Ctrl Alt Meta

Runs entirely in your browser. Nothing you type is uploaded or stored.

How to use this tool

Click anywhere on this page to make sure it has keyboard focus, then press any key. The big box shows the key you pressed, and the four cards below it list the exact property values JavaScript reports for that keystroke: event.key, event.code, event.keyCode, and event.which. The row underneath highlights any modifier keys (Shift, Ctrl, Alt, Meta) that were held at the same time. Use the Copy values button to grab all four values for pasting into your code, and Reset to clear the display.

How key event properties work

document.addEventListener("keydown", function (event) { event.key; // printed character or named key, e.g. "a", "Enter", "ArrowUp" event.code; // physical key on the keyboard, e.g. "KeyA", "Enter", "ArrowUp" event.keyCode; // legacy numeric code (deprecated but still common) event.which; // legacy numeric code, mirrors keyCode });

When you build key event listeners, the property you reach for depends on the goal. event.key gives you what the key means right now, so Shift plus the "1" key returns "!". event.code gives you the physical position of the key regardless of layout, which is what game controls and shortcut handlers usually want. The older event.keyCode and event.which are a numerical code for the key press; they are deprecated in modern specs but you will still see them in legacy code, which is why this keyboard code lookup shows all four side by side.

A real example

Press the letter "A" without holding Shift. The tool reports event.key as "a", event.code as "KeyA", and both event.keyCode and event.which as 65. Now hold Shift and press "A" again: event.key becomes "A" while event.code stays "KeyA" and the numeric codes stay 65, with the Shift badge lit up. That difference is exactly why you check the numerical code or event.code when you want a key to behave the same whether or not Shift is down.

Common questions

What is the difference between event.key and event.code?

event.key is the value the key produces, so it changes with Shift, Caps Lock, and keyboard layout. event.code is the physical key location and stays the same no matter the layout or modifiers, which makes it the better choice for shortcuts and game movement keys.

Why are keyCode and which deprecated?

Both return a single numerical code per key press, but they were never consistent across browsers and layouts. The HTML standard now recommends event.key and event.code instead. You can still read keyCode and which for older code, which is why this finder displays them.

How do I check the key press numerical code in my own listener?

Add a keydown listener and read event.keyCode (or event.which). For example, the Enter key reports 13 and the Escape key reports 27. Press those keys in the tool above to confirm the numbers before you hardcode them.

Why does nothing happen when I press a key?

The page needs keyboard focus. Click anywhere on it first, then press a key. Some keys such as Tab, function keys, and browser shortcuts may be handled by the browser before the page sees them, so a few combinations will not register.

Can I detect modifier keys like Ctrl and Shift?

Yes. Each key event carries the booleans event.shiftKey, event.ctrlKey, event.altKey, and event.metaKey. The badge row in this tool reads those exact properties and highlights the ones that are pressed.