^[control-codes live in libghostty-vt

ANSI modes

KAM Keyboard Action Mode

Lock and unlock the keyboard.

CSI 2 h
ECMA-48
§7.2.11 KAM – Keyboard Action Mode, p. 24
DEC STD 070
§5.10.1.1 ANSI Specified Modes, p. 5-133
VT220
§4.6.3 Keyboard Action Mode (KAM)
VT510
KAM—Keyboard Action Mode
xterm
Functions using CSI

Mode 2 locks the keyboard. Set (CSI 2 h), the keyboard sends nothing to the host; reset (CSI 2 l), which is the default, it works as usual.

StateECMA-48 calls itMeaning
Reset, CSI 2 lENABLEDthe keyboard can be used
Set, CSI 2 hDISABLEDall or part of the keyboard cannot be used

DEC STD 070 lists it among the ANSI modes a DEC terminal accepts, and its keyboard chapter (p. 6-37) says that when it is locked all but the local function keys F1 to F5 are disabled. The VT510 manual adds that the terminal shows its Wait indicator, and that Set-Up and the session key still work.

xterm keeps the mode, and while it is set it ignores what is typed (input.c). It changes only what the keyboard sends, which this site cannot press, so nothing on the screen changes. libghostty-vt keeps the mode too, and both answer DECRQM with its state.

Validation

KAM-1: Reset by default

\e[2$p
|_____|
reply \e[2;2$y

KAM-2: Set

\e[2h
\e[2$p
|_____|
reply \e[2;1$y

KAM-3: And reset again

\e[2h
\e[2l
\e[2$p
|_____|
reply \e[2;2$y

KAM-4: Nothing on the screen changes

A
\e[2h    # lock the keyboard
B
\e[2l
C
|ABC__|
cursor 1,4
Every example on these pages runs in your browser, in libghostty-vt compiled to WebAssembly.