^[control-codes
live in libghostty-vt

ANSI modes

KAM Keyboard Action Mode

View as Markdown

Lock and unlock the keyboard.

CSI 2 h/l
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.

Support

TerminalVersionSupportNotes
VT220manual, 2nd ed., 1984Yes§4.6.3 Keyboard Action Mode (KAM)
VT510manual, 1st ed., 1993YesKAM
xtermpatch 412, xterm-411aYes
libghostty-vt0f171f6Yes
kitty0.49.1, run in a VMNofails the 3 cases that show it working
foot1.28.0, run in a VMNofails the 3 cases that show it working
xterm.js headless6.0.0, run as a libraryNofails the 3 cases that show it working
alacritty_terminal0.26.0, run as a libraryNofails the 3 cases that show it working
ConEmubuild 230724, its documentationNonot in its ANSI escape codes
rxvt-unicode9.31, run in a VMNofails the 3 cases that show it working
VTE0.84.1, run as a libraryNofails the 3 cases that show it working

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.