Online Keyboard Key Code Visualizer. KeyCode Inspector

Free online tool to see the event.key, event.code, event.which and location of any keyboard key in real time. Generates ready-to-use JavaScript code snippets.

Press a key

Any key on your keyboard to see its code

Utilities Studio

Want this utility on your website?

Customize colors and dark mode for WordPress, Notion or your own site.

Frequently Asked Questions

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

event.code represents the physical key on the keyboard, regardless of the configured language. event.key represents the generated character, which may change if you press Shift or use a different language. Use code for game controls; use key for text input and semantic shortcuts.

What is event.which and why is it deprecated?

event.which is a legacy property that returns a numeric ASCII code for the key. It is marked as deprecated in modern standards because event.key and event.code replace it with more precise and readable information. It is shown in this tool for educational purposes.

What does the location property mean?

The location property indicates where the key is physically located on the keyboard: Standard (normal position), Left (left modifier key), Right (right modifier key), or Numpad (numeric keypad). It is useful to distinguish between the left and right CTRL keys, for example.

Does it work with international keyboards and non-QWERTY layouts?

Yes. The tool shows exactly what the browser reports for your keyboard configuration. event.code will always return the QWERTY name of the physical position, while event.key will show the actual character according to your language.

# Understanding keyboard events in JavaScript

When a user presses a key, the browser fires three events: keydown, keypress, and keyup. Each exposes properties with information about the key pressed, but not all are equivalent or recommended.

# Key event properties

event.code — The physical key

Returns the identifier of the physical position of the key on the keyboard, using QWERTY nomenclature. For example, the "A" key on an AZERTY keyboard returns KeyQ. Ideal for game controls where position matters, not the character.

event.key — The generated character

Returns the character value generated according to language and active modifiers. Pressing Shift+A returns "A"; without Shift returns "a". For special keys it returns names like "Enter", "Escape", "ArrowUp".

# When to use each property

Use event.code for game controls (WASD regardless of language) and event.key to detect specific characters or semantic keyboard shortcuts like Ctrl+C.
The event.which and event.keyCode properties are officially deprecated according to the W3C standard. Although modern browsers continue to support them for compatibility, they should not be used in new code.

Bibliographic References