---
title: "Keycode Finder – JavaScript event.key, event.code, keyCode"
description: "Press any key to see its name, event.key, event.code and keyCode, with copy buttons, a JavaScript snippet and an event log. Free, in your browser."
url: https://devicetests.com/keycode
language: en
---

# Keycode finder

Press any key to see its name and every code your browser gets.

> **Interactive test.** This test runs in the browser on the user's own device and uses that device's hardware, so an AI agent can't run it for the user. To use it, the user opens <https://devicetests.com/keycode> in a browser.
>
> **What it needs:** A keyboard on the device: built in, USB or Bluetooth, or the on-screen keyboard through the page's text box. The user presses keys in their own browser, which shows each key event's key, code, keyCode, location and modifiers. Android on-screen keyboards usually report key "Unidentified" and keyCode 229. For a list of common values without pressing anything, the page's static key code table is enough.
>
> **Cost:** Free. Nothing to install and no account.

This keycode finder needs JavaScript to read your key presses. Turn on JavaScript, or open this page in a current Chrome, Edge, Firefox or Safari. The key code table below works without it.

## Quick start

1. Press any key. On a phone, tap the **Text box** first.
2. Read its name, **event.key**, **event.code** and **keyCode**.
3. Press **Copy** next to a value, or **Copy code** for a snippet.

## How to read your results

| What you see | What it means |
| - | - |
| **The big key** | The key you pressed, by name, with any modifier keys you held: Left Shift, Ctrl + S, Numpad Enter. |
| **event.key** | What the key types or does: “a”, “A” with Shift, “Enter”, “ArrowUp”. It changes with your keyboard layout and with Shift. |
| **event.code** | Which key it is: its place on the keyboard, such as “KeyA” or “ShiftRight”. It’s the same on every layout. |
| **event.keyCode** | The old number for the key, such as 65 for A. It’s deprecated, but browsers still send it. |
| **event.location** | 0 for most keys, 1 for a left key, 2 for a right key, 3 for the number pad. |
| **Modifier keys** | Which of Ctrl, Shift, Alt and Meta (Windows key or Cmd) were held down. |
| **On your layout** | What the key types on your keyboard layout, without Shift. Only Chrome and Edge on a computer can tell. |
| **getModifierState()** | Every modifier and lock the browser reports, such as Caps Lock and Num Lock, on or off. |
| **Event log** | Every keydown, keyup and text event, newest first. |

### Which value should I use?

- **event.code** for keys that matter by their place: game controls (WASD), shortcuts, a piano on the keyboard.
- **event.key** for keys that matter by their meaning: Enter, Escape, the arrows, or a typed character such as “?”.
- Not **keyCode** or **which** in new code. They are deprecated and differ between browsers.

> **Tip:** Under **Code to use it**, the tool writes the JavaScript for the key you just pressed, with the modifier keys you held.

### Key code table

| Key | event.code | event.key | keyCode | keyCode in Firefox |
| - | - | - | - | - |
| [Backspace](https://devicetests.com/keycode/backspace) | `Backspace` | `Backspace` | 8 | |
| [Tab](https://devicetests.com/keycode/tab) | `Tab` | `Tab` | 9 | |
| [Enter](https://devicetests.com/keycode/enter) | `Enter` | `Enter` | 13 | |
| [Numpad Enter](https://devicetests.com/keycode/enter) | `NumpadEnter` | `Enter` | 13 | |
| [Left Shift](https://devicetests.com/keycode/shift) | `ShiftLeft` | `Shift` | 16 | |
| [Right Shift](https://devicetests.com/keycode/shift) | `ShiftRight` | `Shift` | 16 | |
| [Left Control](https://devicetests.com/keycode/control) | `ControlLeft` | `Control` | 17 | |
| [Right Control](https://devicetests.com/keycode/control) | `ControlRight` | `Control` | 17 | |
| [Left Alt](https://devicetests.com/keycode/alt) | `AltLeft` | `Alt` | 18 | |
| [Right Alt](https://devicetests.com/keycode/alt) | `AltRight` | `Alt` | 18 | |
| Pause | `Pause` | `Pause` | 19 | |
| [Caps Lock](https://devicetests.com/keycode/caps-lock) | `CapsLock` | `CapsLock` | 20 | |
| [Escape](https://devicetests.com/keycode/escape) | `Escape` | `Escape` | 27 | |
| [Space](https://devicetests.com/keycode/space) | `Space` | `" "` | 32 | |
| [Page Up](https://devicetests.com/keycode/home-end-page-up-page-down) | `PageUp` | `PageUp` | 33 | |
| [Page Down](https://devicetests.com/keycode/home-end-page-up-page-down) | `PageDown` | `PageDown` | 34 | |
| [End](https://devicetests.com/keycode/home-end-page-up-page-down) | `End` | `End` | 35 | |
| [Home](https://devicetests.com/keycode/home-end-page-up-page-down) | `Home` | `Home` | 36 | |
| [Left Arrow](https://devicetests.com/keycode/arrow-keys) | `ArrowLeft` | `ArrowLeft` | 37 | |
| [Up Arrow](https://devicetests.com/keycode/arrow-keys) | `ArrowUp` | `ArrowUp` | 38 | |
| [Right Arrow](https://devicetests.com/keycode/arrow-keys) | `ArrowRight` | `ArrowRight` | 39 | |
| [Down Arrow](https://devicetests.com/keycode/arrow-keys) | `ArrowDown` | `ArrowDown` | 40 | |
| [Print Screen](https://devicetests.com/keycode/print-screen) | `PrintScreen` | `PrintScreen` | 44 | |
| Insert | `Insert` | `Insert` | 45 | |
| [Delete](https://devicetests.com/keycode/delete) | `Delete` | `Delete` | 46 | |
| [0 to 9](https://devicetests.com/keycode/number-keys) | `Digit0 to Digit9` | `0 to 9` | 48 to 57 | |
| [A to Z](https://devicetests.com/keycode/letter-keys) | `KeyA to KeyZ` | `a to z` | 65 to 90 | |
| [Left Windows](https://devicetests.com/keycode/meta) | `MetaLeft` | `Meta` | 91 | |
| Menu | `ContextMenu` | `ContextMenu` | 93 | |
| [Numpad 0 to Numpad 9](https://devicetests.com/keycode/numpad) | `Numpad0 to Numpad9` | `0 to 9` | 96 to 105 | |
| [Numpad Multiply](https://devicetests.com/keycode/numpad) | `NumpadMultiply` | `*` | 106 | |
| [Numpad Plus](https://devicetests.com/keycode/numpad) | `NumpadAdd` | `+` | 107 | |
| [Numpad Minus](https://devicetests.com/keycode/numpad) | `NumpadSubtract` | `-` | 109 | |
| [Numpad Decimal](https://devicetests.com/keycode/numpad) | `NumpadDecimal` | `.` | 110 | |
| [Numpad Divide](https://devicetests.com/keycode/numpad) | `NumpadDivide` | `/` | 111 | |
| [F1 to F12](https://devicetests.com/keycode/function-keys) | `F1 to F12` | `F1 to F12` | 112 to 123 | |
| [Num Lock](https://devicetests.com/keycode/numpad) | `NumLock` | `NumLock` | 144 | |
| Scroll Lock | `ScrollLock` | `ScrollLock` | 145 | |
| Mute | `AudioVolumeMute` | `AudioVolumeMute` | 173 | 181 |
| Volume Down | `AudioVolumeDown` | `AudioVolumeDown` | 174 | 182 |
| Volume Up | `AudioVolumeUp` | `AudioVolumeUp` | 175 | 183 |
| [Semicolon](https://devicetests.com/keycode/punctuation) | `Semicolon` | `;` | 186 | 59 |
| [Equal](https://devicetests.com/keycode/punctuation) | `Equal` | `=` | 187 | 61 |
| [Comma](https://devicetests.com/keycode/punctuation) | `Comma` | `,` | 188 | |
| [Minus](https://devicetests.com/keycode/punctuation) | `Minus` | `-` | 189 | 173 |
| [Period](https://devicetests.com/keycode/punctuation) | `Period` | `.` | 190 | |
| [Slash](https://devicetests.com/keycode/punctuation) | `Slash` | `/` | 191 | |
| [Backquote](https://devicetests.com/keycode/punctuation) | `Backquote` | `` ` `` | 192 | |
| [Left Bracket](https://devicetests.com/keycode/punctuation) | `BracketLeft` | `[` | 219 | |
| [Backslash](https://devicetests.com/keycode/punctuation) | `Backslash` | `\` | 220 | |
| [Right Bracket](https://devicetests.com/keycode/punctuation) | `BracketRight` | `]` | 221 | |
| [Quote](https://devicetests.com/keycode/punctuation) | `Quote` | `'` | 222 | |

### Remapping a key

Remapping apps use their own key names, so you don’t paste these values into them. Use the big key’s name and **event.code** to be sure which key is which. Then pick the key in the app. In PowerToys Keyboard Manager and Karabiner-Elements, you can press the key to pick it.

## If something’s wrong

### Nothing shows when you press a key

Click the key box first. Keys also count from the page itself, but only while the key box is on your screen. Keys typed into the menu search or other fields don’t count.

### A key shows nothing at all

Your keyboard or computer keeps some keys for itself, so the browser never gets them. Fn, brightness keys and many media keys work this way. No website can see these keys.

On Windows, Print Screen sends only a keyup, so it shows when you let go of it.

### A shortcut closed the tab or opened a window

Browsers keep some shortcuts: Ctrl + N, Ctrl + T, Ctrl + W, Ctrl + Tab, Ctrl + Page Up, Ctrl + Page Down and Ctrl + 1 to Ctrl + 9 on Windows, and Cmd + N, Cmd + T, Cmd + W and Cmd + Q on a Mac. Your computer keeps others, such as Alt + F4, Windows + L and Ctrl + Alt + Del. The Windows key on its own opens the Start menu. The page never gets these keys. Other shortcuts, such as Ctrl + S or F5, show in the key box without doing anything.

### On an Android phone, the key is “Unidentified” and keyCode is 229

The keyboard on your screen doesn’t tell websites which key you tapped. It only sends the text. Look for the **input** event in the event log: its data shows what you typed (for a deletion, data is empty and inputType says what happened). To see real key codes, connect a Bluetooth or USB keyboard.

iPhones usually send the real key and keyCode, but event.code is often empty.

### Typing Chinese, Japanese or Korean shows keyCode 229

Your input method builds each character from several keys, so keys show keyCode 229 or key “Process”, and isComposing is true while it works. Browsers differ at the first and last key. Read the finished text from the compositionend or input event. More in [keyCode 229 and “Unidentified” keys](https://devicetests.com/keycode/229).

### The key shows “Dead”

It’s a dead key: it waits for your next key to put an accent on it, such as ´ then e for é. Layouts with accents have them. The key box shows which key it is. To see the accented letter, type the two keys in the **Text box**.

### AltGr also turns on Ctrl and Alt

On Windows, AltGr works as Ctrl and Alt together. Chrome and Edge send a Left Control keydown first, then Right Alt, and ctrlKey and altKey are both true. getModifierState(“AltGraph”) is true too, but Ctrl + Alt can also count as AltGr, so it can’t always tell them apart.

### The key types the wrong character

If **event.code** is right but **event.key** is wrong, your computer uses another keyboard layout. Change it in your computer’s language or keyboard settings. If **event.code** is wrong too, something remaps the key: a remapping app, or your keyboard’s own software.

### On a Mac, keys pressed with Cmd held show no keyup

macOS doesn’t send the keyup of keys pressed while Cmd is held, so browsers can’t always report it.

### keyCode is different in another browser

Firefox usually sends other numbers for a few keys, such as 59 for the ; key where Chrome sends 186 on a US keyboard. Punctuation keys also change with the keyboard layout. Use event.code or event.key instead.

## How this test works

When you press a key, your browser sends the page a keydown event, and a keyup event when you let go. The tool shows the values exactly as your browser sent them. Nothing is changed or guessed, except the key’s name, which comes from event.code.

Inside the key box, the tool stops each key’s usual action, so F5 or Ctrl + S show their codes instead of reloading or saving. Press Esc, then Tab, to leave the key box.

The text box shows what an on-screen keyboard or input method sends. There the text appears as usual, and the event log also lists the beforeinput, input and composition events.

**What the tool can see**

- Every key your browser passes to the page, with all its values.
- What a key types on your layout, in Chrome and Edge on a computer (Keyboard Map API). It may show your main layout rather than the one in use.

**What it can’t see**

- Keys your keyboard or computer keeps for itself, such as Fn.
- Shortcuts your browser or computer keeps, such as Ctrl + W or Alt + F4.
- Scan codes and Windows virtual-key codes.

See [how we test keyboards](https://devicetests.com/how-we-test#keyboards-mice-and-controllers) for where our limits come from, and what a browser can’t measure.

[How we test our tools](https://devicetests.com/how-we-test)

## Questions and answers

**What is a keycode?**

A keycode tells a website which key you pressed. Your browser sends it with every key press, for example 13 for Enter and 65 for A.

Today there are three values. **event.key** is what the key types or does. **event.code** is which key it is on the keyboard. **event.keyCode** is the old number, still sent but deprecated.

**What's the difference between event.key and event.code?**

**event.code** names the key's place on the keyboard, such as KeyQ for the key right of Tab. It stays the same on every layout, so it suits games (WASD) and shortcuts.

**event.key** is what the key types: "q" on a US keyboard, "a" on a French one, "Q" with Shift. Use it when the character matters.

**Is keyCode deprecated? What should I use instead?**

Yes. keyCode, which and charCode are deprecated. Browsers still send them, so old code keeps working, but the numbers differ between browsers and keyboard layouts. In new code, use event.key or event.code.

**Why do I get keyCode 229?**

229 means an input method or an on-screen keyboard took the key. Android keyboards send it for almost every key, with event.key "Unidentified". iPhones usually send the real key. Japanese, Chinese and Korean typing send it while a character is being built. Read the text from the input event instead.

**What key am I pressing?**

Press it in the key box. The big key shows its name, such as Right Alt or Numpad Enter. The event.code value beside it names the exact key, the same on every keyboard layout.

**Can I see a key's scan code?**

No. Browsers don't give websites the scan code or the Windows virtual-key code. On Windows, AutoHotkey's Key History window shows both.

**Does this site record what I type?**

No. The page shows your key presses on your screen only. It doesn't save or send them.

## Related tests

- [Keyboard tester](https://devicetests.com/keyboard-tester): Check that every key on your keyboard works.
- [Keyboard ghosting test](https://devicetests.com/keyboard-ghosting-test): See how many keys your keyboard can send at the same time.
- [Keyboard chatter test](https://devicetests.com/keyboard-chatter-test): Find keys that type twice when you press them once.
- [Rapid trigger test](https://devicetests.com/rapid-trigger-test): Time how fast your keys reset, and see which key wins when you hold A and D (Snap Tap).
- [Keyboard polling rate test](https://devicetests.com/keyboard-polling-rate-test): See how often your keyboard reports key presses, and the delay that adds.
