# Keypad Application and Numeric Modes (DECKPAM, DECKPNM)

> Choose what the numeric keypad sends: its digits or application codes.

- **Sequence:** `ESC =`
- **DEC STD 070:** [§6.9 Set Keypad Application Mode, p. 6-66](https://archive.org/details/bitsavers_decstandar0VideoSystemsReferenceManualDec91_74264381/page/n552/mode/1up)
- **VT220:** [§4.6.18 Keypad Mode (DECKPAM/DECKPNM)](https://vt100.net/docs/vt220-rm/chapter4.html#S4.6.18)
- **VT510:** [DECKPAM—Keypad Application Mode](https://vt100.net/docs/vt510-rm/DECKPAM.html)

`ESC =` (DECKPAM) puts the numeric keypad into *application* mode, and
`ESC >` (DECKPNM) puts it back into *numeric* mode, the default. In numeric
mode the keypad's keys send the digits, comma, period and minus sign printed
on them. In application mode they send SS3 followed by a single character
identifying the key.

DECKPNM is defined in DEC STD 070
[§6.9, p. 6-67](https://archive.org/details/bitsavers_decstandar0VideoSystemsReferenceManualDec91_74264381/page/n553/mode/1up) and in the VT510 manual as
[DECKPNM—Keypad Numeric Mode](https://vt100.net/docs/vt510-rm/DECKPNM.html).

The same setting is DEC private mode 66, DECNKM: `CSI ? 66 h` is the same as
DECKPAM, and `CSI ? 66 l` the same as DECKPNM. DEC STD 070
([§6.9, p. 6-68](https://archive.org/details/bitsavers_decstandar0VideoSystemsReferenceManualDec91_74264381/page/n554/mode/1up))
says it was added to make it simpler to ask for the keypad's state; the
VT510 manual has it as [DECNKM](https://vt100.net/docs/vt510-rm/DECNKM.html).
DEC STD 070 requires, from level 2, that this mode and the cursor key mode
([DECCKM](https://control-codes.page/modes/decckm/index.html.md)) be independent of each other.

This site cannot press keys, so the cases check only the mode, through
DECRQM for mode 66, and that nothing on the screen changes.

## Support

| Terminal | Version | Support | Notes |
| --- | --- | --- | --- |
| VT220 | [manual](https://vt100.net/docs/vt220-rm/), 2nd ed., 1984 | Partly | [§4.6.18 Keypad Mode (DECKPAM/DECKPNM)](https://vt100.net/docs/vt220-rm/chapter4.html#S4.6.18); no DECNKM, mode 66 |
| VT510 | [manual](https://vt100.net/docs/vt510-rm/), 1st ed., 1993 | Yes | [DECKPAM](https://vt100.net/docs/vt510-rm/DECKPAM.html), [DECKPNM](https://vt100.net/docs/vt510-rm/DECKPNM.html), [DECNKM](https://vt100.net/docs/vt510-rm/DECNKM.html) |
| xterm | patch 412, [xterm-411a](https://github.com/ThomasDickey/xterm-snapshots/tree/xterm-411a) | Yes |  |
| libghostty-vt | [0f171f6](https://github.com/ghostty-org/ghostty/tree/0f171f650a1cbbd6df4a2573b6b0c7de57cc6d90) | Yes |  |
| kitty | 0.49.1, [run in a VM](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/kitty.json) | No | fails the 4 cases that show it working |
| foot | 1.28.0, [run in a VM](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/foot.json) | Yes | passes the 4 cases that show it working |
| xterm.js headless | 6.0.0, [run as a library](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/xtermjs.json) | Yes | passes the 4 cases that show it working |
| alacritty_terminal | 0.26.0, [run as a library](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/alacritty.json) | No | fails the 4 cases that show it working |
| ConEmu | build 230724, its [documentation](https://conemu.github.io/en/AnsiEscapeCodes.html) | No | lists DECCKM but not DECKPAM, DECKPNM or mode 66, in [ANSI escape codes](https://conemu.github.io/en/AnsiEscapeCodes.html) |
| rxvt-unicode | 9.31, [run in a VM](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/urxvt.json) | Yes | passes the 4 cases that show it working |
| VTE | 0.84.1, [run as a library](https://git.jcollie.dev/jeff/control-codes/src/branch/main/emulators/results/vte.json) | Yes | passes the 4 cases that show it working |

## Validation

### DECKPAM-1: Application mode

Input, one step per line:

```text
\e=
AB
\e[?66$p  # DECRQM: is mode 66 set?
```

Expected screen:

```text
|AB___|
reply \e[?66;1$y
```

### DECKPAM-2: Back to numeric mode

Input, one step per line:

```text
\e=
\e>
\e[?66$p
```

Expected screen:

```text
|_____|
reply \e[?66;2$y
```

### DECKPAM-3: The same setting as mode 66

Input, one step per line:

```text
\e[?66h   # DECNKM, set
\e[?66$p
\e[?66l   # DECNKM, reset
\e[?66$p
```

Expected screen:

```text
|_____|
reply \e[?66;1$y\e[?66;2$y
```

### DECKPAM-4: Numeric mode to begin with

Input, one step per line:

```text
\e[?66$p
```

Expected screen:

```text
|_____|
reply \e[?66;2$y
```

---

This is the Markdown version of <https://control-codes.page/esc/deckpam/>. On that page every validation case runs live in libghostty-vt, the terminal emulation core of Ghostty, compiled to WebAssembly.

The validation cases are written in the notation described in <https://control-codes.page/notation/index.html.md>.
