^[control-codes live in libghostty-vt
View as Markdown

Choose whether keys with modifiers are sent as CSI 27 ; m ; code ~ or as CSI code ; m u, and ask which is chosen.

XTFMTKEYS Set Key Format Options

CSI > Pp ; Pv f

XTQFMTKEYS Query Key Format Options

CSI > Pm g
xterm
Functions using CSI

XTMODKEYS says whether xterm sends a key with its modifiers as an escape sequence; these say how. Each of xterm’s modify…Keys resources has a format…Keys companion, and for the keys modifyOtherKeys covers, formatOtherKeys chooses between two forms of Control and ,:

formatOtherKeysSends
0, the defaultCSI 27 ; 5 ; 44 ~, function key 27 with the modifiers and the character
1CSI 44 ; 5 u, the character with the modifiers

The second is the form proposed by fixterms, and xterm added formatOtherKeys at its author’s request, in patch 235 (2008), as a resource only (modifyOtherKey). Patch 398 (2025) gave the other key categories a format resource each and added these sequences to set and ask for them, so a program can now ask for the CSI u form itself, with CSI > 4 ; 1 f alongside CSI > 4 ; 2 m.

Pp picks the resource, numbered as for XTMODKEYS:

PpResourceDefault
0formatKeyboard0
1formatCursorKeys0
2formatFunctionKeys0
3formatKeypadKeys0
4formatOtherKeys0
6formatModifierKeys0
7formatSpecialKeys0

5 is reserved, as it is for XTMODKEYS. formatKeyboard has no resource to set it from, so it starts at 0 and only these sequences change it. The others take effect only where their modify…Keys resource is high enough to send an escape sequence at all.

The forms, in a default xterm (CASE_SET_FMT_KEYS, set_fmt_fkeys, report_fmt_fkeys):

  • CSI > Pp ; Pv f sets one to Pv, which is not checked. CSI > Pp f, with no value, puts it back as it started. CSI > f changes nothing: the code has a branch that would put back 1 to 5 when there are no parameters, but xterm counts an empty list as one parameter with its default, -1, so the branch is never taken and resource -1 is set, which there is none of.
  • CSI > Pp g asks, and is answered as CSI > Pp ; Pv f, a sequence that would set it back; several at once, CSI > 1 ; 4 g, get an answer each. A resource xterm does not have is answered with 65535, the -1 it stands for read as sixteen unsigned bits, and so CSI > g, which asks about resource -1, is answered CSI > 65535 ; 65535 f.
  • DECRQSS asks as well, as DCS $ q > Pp f ST, but the answer ends in m, as XTQMODKEYS’s does: DCS 1 $ r > Pp ; Pv m ST (misc.c). Sent back, that would set the XTMODKEYS resource of the same number.
  • DECSTR and RIS put them all back as they started (ReallyReset).

xterm’s own Control Sequences documents the query as CSI ? Pp g (ctlseqs.ms), but its parser has the query only in the CSI > table, beside the set (dec2_table); in the CSI ? table g goes to the ground state (dec_table). So CSI ? 4 g is not answered, and CSI > 4 g is.

libghostty-vt ignores all of it: it reads the > and ? as intermediates and ignores f and g with any, so neither moves the cursor as HVP or clears a tab stop as TBC would. Its key encoder never sends the CSI u form for modifyOtherKeys. The cases follow a default xterm, so those that ask are known differences.

None of the other terminals this site runs has it, and two of them misread it. kitty 0.49.1 takes CSI > 2 ; 5 f for HVP and moves the cursor (XTFMTKEYS-10). pyte does the same, takes CSI > g for TBC and clears a tab stop (XTFMTKEYS-11), and raises an exception on CSI ? 4 g, which it hands to its tab-clearing method with a private argument the method does not take (XTFMTKEYS-9).

Support

TerminalVersionSupportNotes
VT220manual, 2nd ed., 1984Nonot in the manual
VT510manual, 1st ed., 1993Nonot in the manual
xtermpatch 412, xterm-411aYes
libghostty-vt919dca5Noignores both (XTFMTKEYS-1 to XTFMTKEYS-8, XTFMTKEYS-12)
kitty0.49.1, run in a VMNofails the 2 cases that show it working
foot1.28.0, run in a VMNofails the 2 cases that show it working
pyte0.8.2, run as a libraryNofails the 2 cases that show it working
xterm.js headless6.0.0, run as a libraryNofails the 2 cases that show it working
alacritty_terminal0.26.0, run as a libraryNofails the 2 cases that show it working
ConEmubuild 230724, its documentationNonot in ConEmu’s list; ANSI escape codes
rxvt-unicode9.31, run in a VMNofails the 2 cases that show it working
VTE0.84.1, run as a libraryNofails the 2 cases that show it working

Validation

XTFMTKEYS-1: The defaults

\e[>0;1;2;3;4;6;7g
|______|
reply \e[>0;0f\e[>1;0f\e[>2;0f\e[>3;0f\e[>4;0f\e[>6;0f\e[>7;0f

XTFMTKEYS-2: The fixterms form for modifyOtherKeys

\e[>4;1f
\e[>4g
|______|
reply \e[>4;1f

XTFMTKEYS-3: Put it back

\e[>4;1f
\e[>4f
\e[>4g
|______|
reply \e[>4;0f

XTFMTKEYS-4: Without a resource, nothing changes

\e[>1;1f
\e[>4;1f
\e[>6;1f
\e[>f
\e[>1;4;6g
|______|
reply \e[>1;1f\e[>4;1f\e[>6;1f

XTFMTKEYS-5: The value is not checked

\e[>4;9f
\e[>4g
|______|
reply \e[>4;9f

XTFMTKEYS-6: A resource xterm does not have

\e[>8g
|______|
reply \e[>8;65535f

XTFMTKEYS-7: DECSTR puts them back

\e[>4;1f
\e[!p
\e[>4g
|______|
reply \e[>4;0f

XTFMTKEYS-8: Through DECRQSS, ending in m

\e[>4;1f
\eP$q>4f\e\\
|______|
reply \eP1$r>4;1m\e\\

XTFMTKEYS-9: The documented query is not answered

\e[?4g
|______|
reply none

XTFMTKEYS-10: Not HVP

A
\e[>2;5f
B
|AB______|
|________|
cursor 1,3

XTFMTKEYS-11: Not TBC

\t        # to the stop at column 9
\e[>g     # what TBC would read as clearing it
\r\t
X
|________X___________|

XTFMTKEYS-12: A query with nothing to ask

\e[>g
|______|
reply \e[>65535;65535f
Every example on these pages runs in your browser, in libghostty-vt compiled to WebAssembly.