---
title: "Letter Key Codes: A–Z keyCode 65–90, event.key, event.code"
description: "Letters send keyCode 65 to 90, event.code \"KeyA\" to \"KeyZ\" and event.key \"a\" or \"A\". See when to use key or code, so shortcuts and WASD work on any layout."
url: https://devicetests.com/keycode/letter-keys
language: en
---

# Letter key codes (A–Z)

Letter keys send event.code "KeyA" to "KeyZ", event.key "a" to "z" on a US layout ("A" to "Z" with Shift or Caps Lock) and keyCode 65 to 90.

## Every value at a glance

| Key | event.code | event.key | keyCode | event.location |
| - | - | - | - | - |
| A | `KeyA` | `a` | 65 | 0 (Standard) |
| B | `KeyB` | `b` | 66 | 0 (Standard) |
| C | `KeyC` | `c` | 67 | 0 (Standard) |
| D | `KeyD` | `d` | 68 | 0 (Standard) |
| E | `KeyE` | `e` | 69 | 0 (Standard) |
| F | `KeyF` | `f` | 70 | 0 (Standard) |
| G | `KeyG` | `g` | 71 | 0 (Standard) |
| H | `KeyH` | `h` | 72 | 0 (Standard) |
| I | `KeyI` | `i` | 73 | 0 (Standard) |
| J | `KeyJ` | `j` | 74 | 0 (Standard) |
| K | `KeyK` | `k` | 75 | 0 (Standard) |
| L | `KeyL` | `l` | 76 | 0 (Standard) |
| M | `KeyM` | `m` | 77 | 0 (Standard) |
| N | `KeyN` | `n` | 78 | 0 (Standard) |
| O | `KeyO` | `o` | 79 | 0 (Standard) |
| P | `KeyP` | `p` | 80 | 0 (Standard) |
| Q | `KeyQ` | `q` | 81 | 0 (Standard) |
| R | `KeyR` | `r` | 82 | 0 (Standard) |
| S | `KeyS` | `s` | 83 | 0 (Standard) |
| T | `KeyT` | `t` | 84 | 0 (Standard) |
| U | `KeyU` | `u` | 85 | 0 (Standard) |
| V | `KeyV` | `v` | 86 | 0 (Standard) |
| W | `KeyW` | `w` | 87 | 0 (Standard) |
| X | `KeyX` | `x` | 88 | 0 (Standard) |
| Y | `KeyY` | `y` | 89 | 0 (Standard) |
| Z | `KeyZ` | `z` | 90 | 0 (Standard) |

keyCode as Chrome and Edge send it on Windows. The Mac column (Chrome and Safari on a Mac) and the Firefox column show only numbers that differ; some keys also differ by system, as the text below says. event.which is always the same number as keyCode. event.key is for a US layout without Shift.

## Code to react to A

Recommended: match event.key

```
document.addEventListener('keydown', (event) => {
  if (event.key === 'a') {
    // Your code here
  }
});
```

Match the key's place: event.code

```
document.addEventListener('keydown', (event) => {
  if (event.code === 'KeyA') {
    // Your code here
  }
});
```

Old code that still uses keyCode (deprecated)

```
document.addEventListener('keydown', (event) => {
  if (event.keyCode === 65) {
    // Your code here
  }
});
```

## Which value to use

It depends on whether the letter matters or the place on the keyboard.

For typed letters and shortcuts named after a letter, such as Ctrl + Z for undo, check `event.key`. It follows the user’s layout, so the shortcut works on the key that shows a Z.

For keys picked by their place, such as WASD in a game, check `event.code`. `KeyW` is the key above S on every layout, even on a French AZERTY keyboard where it types “z”.

`keyCode` is the number of the uppercase letter, 65 for A to 90 for Z, with or without Shift. On Latin layouts it usually follows the letter typed: on AZERTY, the key with code `KeyQ` types “a” and sends 65. On Russian, Greek and other non-Latin layouts it is usually the US letter in that place.

## What trips people up

### event.key is “A” instead of “a”

Shift and Caps Lock change `event.key`. Compare in lowercase, `event.key.toLowerCase() === 'a'`, and check `event.shiftKey` on its own if Shift matters. This also helps on a Mac, where Cmd + Shift + Z can arrive as a lowercase “z”.

### WASD controls don’t work on a French keyboard

If you check `event.key === 'w'`, AZERTY players must reach for the W at the bottom left. Check `event.code` (`KeyW`, `KeyA`, `KeyS`, `KeyD`) so the keys stay in the same place. To show the right letters in your help text, Chrome and Edge can tell you what a code types: `navigator.keyboard.getLayoutMap()`.

### Ctrl+Z lands on the wrong key on German or French keyboards

German QWERTZ swaps Z and Y, and on AZERTY the Z sits where W is on a US keyboard. A shortcut checked with `event.code === 'KeyZ'` makes German users press the key labelled Y. Match letter shortcuts with `event.key`.

### Shortcuts stop working on a Russian or Greek layout

There `event.key` is the letter of that alphabet: Ctrl + Z on a Russian layout sends “я”. Fall back to the place when the key isn’t a Latin letter:

```
const letter = /^[a-z]$/i.test(event.key)
  ? event.key.toLowerCase()
  : event.code.startsWith('Key') ? event.code.slice(3).toLowerCase() : '';
```

### Alt+letter types a character on a Mac

Option + S types “ß”, so `event.key` is “ß”, not “s”. Option + E is a dead key: `event.key` is “Dead” and the next letter gets the accent. Match Alt shortcuts with `event.code` and `event.altKey`. On Windows, layouts with AltGr do the same with Ctrl + Alt: Ctrl + Alt + E types € on a German keyboard, so avoid Ctrl + Alt + letter shortcuts.

## Related keys

- [Number key codes (0–9)](https://devicetests.com/keycode/number-keys)
- [Shift key code](https://devicetests.com/keycode/shift)
- [Caps Lock key code](https://devicetests.com/keycode/caps-lock)
- [Alt key code](https://devicetests.com/keycode/alt)
- [Control key code](https://devicetests.com/keycode/control)
- [Keycode finder: press any key to see its codes](https://devicetests.com/keycode)
- [All key codes in one table](https://devicetests.com/keycode#key-codes)
