Keycode Info

About this tool

Keycode Info shows which values the browser reports in the keyboard event for every key you press: event.key, event.code and the old numeric event.keyCode. It also shows held modifiers, the key's location and further values. Use it to look up a keypress for your own code or to check whether and how a key arrives at all. The tool runs entirely in your browser and sends no keystrokes anywhere. It is made for web and game developers, but also for anyone curious what their keyboard reports.

What you can use it for

Frequently asked questions

How do I find the keyCode of a key?

Click into the keyboard area and press the key. The keyCode appears next to key and code in the large display. Note that event.keyCode is deprecated and meant for old code only.

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

event.key is the character or name the key produces with the current layout and modifiers, such as “a” or “A”. event.code identifies the physical key, such as “KeyA”, regardless of layout. Use key for text input and shortcuts, code for game controls like WASD.

Should I still use event.keyCode?

No. event.keyCode and event.which are deprecated. Browsers mostly still support them, but new code should use key or code instead.

Why does the Z key on a German keyboard show the code KeyY?

code names a key by its position on a US keyboard. On a German keyboard the Z sits where the US layout has the Y, so the code stays KeyY, while key returns “z”.

What do “Dead”, “Process” and “Unidentified” mean for key?

“Dead” is a dead key such as ^ or ´, where the character only appears with the next key. “Process” reports IME input. “Unidentified” means the system cannot tell which key it was, which is typical on phone on-screen keyboards.

Why does the tool not detect keys on my phone?

On-screen keyboards often do not report real keys, so key arrives as “Unidentified”. Type into the input field instead: the input event shows which character arrived.

What does event.location mean?

It tells where a key that exists more than once sits: 0 standard, 1 left, 2 right, 3 numpad. The specification also defines 4 for mobile and 5 for joystick or game controller.

Are my keystrokes stored or sent?

No. The tool works only in your browser and sends nothing. The history of recent keys exists only on the page itself.

Does the tool trap me with Tab?

No. Tab and Shift+Tab are shown but never blocked, and focus moves on. Browser shortcuts with Ctrl, Alt or Win stay with the browser.

Background

When a key is pressed in the browser, it fires keyboard events: keydown when pressed and keyup when released. These events carry several properties that serve quite different purposes.

event.key gives the logical value of the key. It depends on the keyboard layout and on held modifiers: with Shift, “a” becomes “A”. This is the right choice for text input and shortcuts such as Ctrl+S. event.code, by contrast, describes the physical key, for example “KeyA”, “Digit1” or “ShiftLeft”. It names the key by its position on a US keyboard and therefore stays the same on every layout. That makes it suitable for game controls like WASD, which should sit in the same place everywhere. An example from the specification: the keys Digit2 and KeyQ give “2” and “q” on a US layout, but “é” and “a” on a French one.

event.keyCode and event.which are older numeric values. Both are deprecated and meant for existing code only. Since many older tutorials still use them, developers nevertheless often search for the numeric value of a key.

Other properties complete the picture. event.location distinguishes identical keys: 0 standard, 1 left, 2 right, 3 numpad, 4 mobile, 5 joystick. event.repeat is true when a held key auto-repeats. shiftKey, ctrlKey, altKey and metaKey show held modifiers, while getModifierState() additionally reveals locked keys such as CapsLock and NumLock, as well as AltGraph. On Windows, AltGr often reports Ctrl and Alt at the same time.

Input methods create special cases. With dead keys such as ^ or ´, key reports “Dead”, and the character only appears with the next key. During IME input it reports “Process”, and isComposing is true while the composition runs between compositionstart and compositionend; shortcuts should not fire then. On phone on-screen keyboards, key often arrives as “Unidentified”, and the input event delivers the actual character.

Layouts differ as well: on German (ISO) keyboards the Z sits where US has the Y, yet the code remains KeyY. The extra key to the left of the left Shift has the code IntlBackslash, which the US (ANSI) layout does not have.

Help & info

key, code and keyCode — which is which?

event.key is the character or name the key produces with the current layout and modifiers (“a”, “A”, “Enter”, “ArrowLeft”) — right for text input and shortcuts like Ctrl+S. event.code is the physical key (“KeyA”, “Digit1”, “ShiftLeft”), independent of the layout — right for game controls like WASD that should sit in the same place on every layout. The specification’s example: Digit2 and KeyQ give “2” and “q” on a US layout, “é” and “a” on a French one. event.keyCode and event.which are deprecated (MDN: “Deprecated”) and meant for old code only.

Why Y and Z are swapped

code names the key by its position on a US keyboard. On a German keyboard the “Z” sits where US has the “Y” — the code is still KeyY. The extra key of the ISO layout left of the left Shift (on German: “<”) has the code IntlBackslash; the “#” key next to Enter is Backslash. The US layout has no IntlBackslash.

location: left, right, numpad

For keys that exist more than once: 0 = standard, 1 = left, 2 = right (e.g. the two Shift keys), 3 = numpad (digits and operators there). The specification also knows 4 = mobile and 5 = joystick / game controller. The NumLock key itself reports 0.

Modifiers and lock keys

shiftKey, ctrlKey, altKey and metaKey tell whether the key is held during the event. getModifierState() returns true when a modifier is pressed or locked — so CapsLock and NumLock show up, and AltGraph. On Windows, AltGr often reports Ctrl and Alt at the same time; build shortcuts on it only if you check AltGraph too.

Dead, Process, Unidentified, isComposing

key = “Dead”: a dead key (e.g. ^ or ´), the character appears only with the next key. “Compose” is the Compose key, “Process” an IME input, “Unidentified” means the system cannot tell which key it was — typical on phone on-screen keyboards, where the input event helps. isComposing is true while an input runs between compositionstart and compositionend; shortcuts should not fire then.

repeat, keydown and keyup

Hold a key and keydown fires again and again with repeat = true; keyup comes once on release. The history counts repeats on the entry (×n) instead of flooding. Some systems report single keys (e.g. Print Screen) only as keyup — the tool also shows a keyup it saw no keydown for.

Operation and keyboard traps

The tool captures keys as long as focus is not in an input field, on a button or on a link — a click on a free spot of the page or on the keyboard picture is enough. Tab and Shift+Tab are shown but never blocked: focus moves on. Esc, arrows, Space and Backspace are shown and do nothing else. Ctrl, Alt and Win shortcuts as well as F11 and F12 stay with the browser.

⚠️ Bitte beachten

Die Werkzeuge auf dieser Website werden als kostenloses Hobbyangebot bereitgestellt und dienen ausschließlich zur Information und privaten Nutzung. Für die Richtigkeit, Vollständigkeit oder Eignung der Ergebnisse für einen bestimmten Zweck wird keine Gewähr übernommen. Vor Verwendung der Ergebnisse — insbesondere bei finanziellen, rechtlichen oder sicherheitsrelevanten Entscheidungen — sind diese eigenverantwortlich zu prüfen. Eine Haftung für Schäden aus der Nutzung ist ausgeschlossen, soweit dies gesetzlich zulässig ist.