# 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.

## 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>.
