---
title: "Numpad Key Codes: keyCode 96–111, NumLock 144 and event.code"
description: "Numpad digits send keyCode 96–105 and event.code \"Numpad0\" to \"Numpad9\", operators 106–111, Num Lock 144. What changes with Num Lock off and on a Mac."
url: https://devicetests.com/keycode/numpad
language: en
---

# Numpad key codes

Numpad digits send event.code "Numpad0" to "Numpad9", event.key "0" to "9" and keyCode 96 to 105; the operators send 106 to 111 and Num Lock 144.

## Every value at a glance

| Key | event.code | event.key | keyCode | keyCode on a Mac | event.location |
| - | - | - | - | - | - |
| Numpad 0 | `Numpad0` | `0` | 96 | | 3 (Number pad) |
| Numpad 1 | `Numpad1` | `1` | 97 | | 3 (Number pad) |
| Numpad 2 | `Numpad2` | `2` | 98 | | 3 (Number pad) |
| Numpad 3 | `Numpad3` | `3` | 99 | | 3 (Number pad) |
| Numpad 4 | `Numpad4` | `4` | 100 | | 3 (Number pad) |
| Numpad 5 | `Numpad5` | `5` | 101 | | 3 (Number pad) |
| Numpad 6 | `Numpad6` | `6` | 102 | | 3 (Number pad) |
| Numpad 7 | `Numpad7` | `7` | 103 | | 3 (Number pad) |
| Numpad 8 | `Numpad8` | `8` | 104 | | 3 (Number pad) |
| Numpad 9 | `Numpad9` | `9` | 105 | | 3 (Number pad) |
| Numpad Multiply | `NumpadMultiply` | `*` | 106 | | 3 (Number pad) |
| Numpad Plus | `NumpadAdd` | `+` | 107 | | 3 (Number pad) |
| Numpad Minus | `NumpadSubtract` | `-` | 109 | | 3 (Number pad) |
| Numpad Decimal | `NumpadDecimal` | `.` | 110 | | 3 (Number pad) |
| Numpad Divide | `NumpadDivide` | `/` | 111 | | 3 (Number pad) |
| Numpad Enter | `NumpadEnter` | `Enter` | 13 | | 3 (Number pad) |
| Num Lock / Clear | `NumLock` | `NumLock` | 144 | 12 | 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 Numpad 0

Recommended: match event.key

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

Match the key's place: event.code

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

Old code that still uses keyCode (deprecated)

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

## Which value to use

For typed digits and operators, check `event.key`. It is “1”, “+” or “\*”, the same as on the main keys, so one check covers both.

Use `event.code` (`Numpad1`, `NumpadAdd`) only when the number pad must do something of its own, such as moving in eight directions in a game. `event.location` is 3 for number pad keys, another way to tell them apart.

`keyCode` is 96 to 105 for the digits, then 106 for \*, 107 for +, 109 for -, 110 for the decimal key and 111 for /. The number pad’s Enter sends 13 like the main Enter.

## What trips people up

### With Num Lock off, Numpad4 sends ArrowLeft

On Windows and Linux, the digit keys turn into navigation keys when Num Lock is off. `Numpad4` then sends `event.key` “ArrowLeft” and keyCode 37, but `event.code` stays “Numpad4”. Numpad0 sends “Insert”, Numpad5 “Clear” (keyCode 12) and the decimal key “Delete”. If digits are missing, check `event.getModifierState('NumLock')` and ask the user to turn Num Lock on.

### Num Lock sends keyCode 12 on a Mac

Mac keyboards have a Clear key in that place, and the number pad always types digits. It sends `event.code` “NumLock”, but `event.key` “Clear” and keyCode 12 instead of 144.

### The decimal key types a comma

On German and many other layouts, `NumpadDecimal` types “,”. `event.key` is “,” while keyCode usually stays 110. If you read numbers, accept both “.” and “,”.

### A Mac number pad has an = key

Full-size Apple keyboards add an = key: `event.code` “NumpadEqual”, `event.key` “=”. It isn’t in the table above, because PC keyboards rarely have it. Its keyCode is 187 in Chrome and Safari on a Mac and 61 in Firefox (on Windows, 12), so match it by key or code.

### Many keyboards have no number pad

Laptops, compact keyboards and phones have none. Never require number pad keys: accept the top-row digits too, which a check on `event.key` does. Some laptops hide a number pad in the letter keys, switched on with Num Lock; while it is on, those letters send number pad codes.

## Related keys

- [Number key codes (0–9)](https://devicetests.com/keycode/number-keys)
- [Enter key code](https://devicetests.com/keycode/enter)
- [Arrow key codes](https://devicetests.com/keycode/arrow-keys)
- [Home, End, Page Up and Page Down key codes](https://devicetests.com/keycode/home-end-page-up-page-down)
- [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)
