Skip to content
gohacks.dev
Standard Library

JavaScript Key Code Inspector

Press any key and see the event.key, event.code, deprecated keyCode, location and modifiers the browser reports, with a history of recent presses.

Free · No sign-up · Your inputs stay in your browser

Input

See what a key press reports

Press any key. Clicks into a text field are ignored.

Output

Waiting for a key

Use event.key for what the key means (it follows the keyboard layout: 'z' on a German keyboard is where 'y' is on a US one) and event.code for its physical position (WASD in games). keyCode and which are deprecated and differ between browsers; they are shown because old code still reads them.

Runs in this browser. Nothing you paste is sent to a server.

key or code

event.key is what the key means under the current layout: 'z', 'Z', 'Enter', 'ArrowUp'. event.code is the physical key, named after its position on a US keyboard: 'KeyZ' on a German keyboard is where the Y is printed. Shortcuts and text input want key; games using WASD want code. The values are defined in the UI Events KeyboardEvent key values and code values specifications.

keyCode is deprecated

keyCode and which are numeric, layout-dependent and inconsistent between browsers. They still work and older code relies on them, which is why they are shown here, but new code should not.

Share

Frequently asked questions

What is the key code for Enter?
event.key is 'Enter' and event.code is 'Enter' (or 'NumpadEnter'); the deprecated keyCode is 13.
How do I detect Ctrl or Cmd plus a key?
Check event.ctrlKey or event.metaKey together with event.key. On macOS, shortcuts conventionally use metaKey (Cmd).
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools