# Cursor Keys Mode (DECCKM)

> Choose what the arrow keys send: cursor movement or application codes.

- **Sequence:** `CSI ? 1 h/l`
- **DEC STD 070:** [§6.8 Set/Reset Cursor Key Mode, p. 6-62](https://archive.org/details/bitsavers_decstandar0VideoSystemsReferenceManualDec91_74264381/page/n548/mode/1up)
- **VT220:** [§4.6.8 Cursor Key Mode (DECCKM)](https://vt100.net/docs/vt220-rm/chapter4.html#S4.6.8)
- **VT510:** [DECCKM—Cursor Keys Mode](https://vt100.net/docs/vt510-rm/DECCKM.html)

`CSI ? 1 h` sets cursor keys mode to *application* and `CSI ? 1 l` resets
it to *cursor*, the default. It changes what the four arrow keys send to the
host. Reset, they send ANSI cursor movement sequences, `ESC [ A` for up.
Set, they send application codes introduced by SS3 instead, `ESC O A` for up,
similar to what the numeric keypad sends in application mode. DEC STD 070
tabulates both sets of codes in
[§6.8.2, p. 6-61](https://archive.org/details/bitsavers_decstandar0VideoSystemsReferenceManualDec91_74264381/page/n547/mode/1up).

DEC STD 070 requires, from level 2, that this mode and the keypad mode
([DECKPAM](https://control-codes.page/esc/deckpam/index.html.md)) be independent of each other.

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

## Support

| Terminal | Version | Support | Notes |
| --- | --- | --- | --- |
| VT220 | [manual](https://vt100.net/docs/vt220-rm/), 2nd ed., 1984 | Yes | [§4.6.8 Cursor Key Mode (DECCKM)](https://vt100.net/docs/vt220-rm/chapter4.html#S4.6.8) |
| VT510 | [manual](https://vt100.net/docs/vt510-rm/), 1st ed., 1993 | Yes | [DECCKM](https://vt100.net/docs/vt510-rm/DECCKM.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) | Yes | passes the 3 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 3 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 3 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) | Yes | passes the 3 cases that show it working |
| ConEmu | build 230724, its [documentation](https://conemu.github.io/en/AnsiEscapeCodes.html) | Yes | [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 3 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 3 cases that show it working |

## Validation

### DECCKM-1: Set

Input, one step per line:

```text
\e[?1h
AB
\e[?1$p   # DECRQM: is mode 1 set?
```

Expected screen:

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

### DECCKM-2: Reset

Input, one step per line:

```text
\e[?1h
\e[?1l
\e[?1$p
```

Expected screen:

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

### DECCKM-3: Cursor mode to begin with

Input, one step per line:

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

Expected screen:

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

---

This is the Markdown version of <https://control-codes.page/modes/decckm/>. 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>.
