JS Keycode Inspector

Press any key on your keyboard to instantly capture JavaScript event codes, key properties, and active modifier structures.

⌨️ Press Capture Area

-
CLICK HERE & PRESS ANY KEY
event.key -
event.code -
event.which -
event.location -
Ctrl Shift Alt Meta / ⌘

📋 Key event properties

Press a key to view properties...

🕒 History Log

  • No keys pressed yet.

Understanding Keyboard Events in JavaScript

Whenever a user interacts with a keyboard in the browser, the document fires specific user-interface events: keydown, keypress, and keyup. Developers capture these events to build custom keyboard navigation, build game loops, or set up accessibility shortcuts.

Managing keyboard inputs has historically been complex due to varying mappings between operating systems and physical hardware keyboard standards. Modern W3C standards advise migrating away from integer key identifiers (like which or keyCode) in favor of the string-based key and code properties.

Important event Properties Detailed

Frequently Asked Questions

event.key represents the character value generated by the keypress, taking keyboard layouts and modifiers into account (e.g. 'A' or 'a'). event.code represents the physical key pressed on the keyboard, independent of layout or modifier states (e.g. 'KeyA').

They are deprecated because they are inconsistent across browsers, platforms, and keyboard layouts. Modern applications should use event.key and event.code instead, which provide standard, reliable string representations of inputs.

The event.location property returns an unsigned long representing the physical location of the key on the keyboard: 0 for standard/default, 1 for left-side keys (like Left Shift), 2 for right-side keys (like Right Alt), and 3 for the numeric keypad.