XTQMODKEYS — Query modifyKeys current value (CSI ? Pp m)
Ask xterm what the current modifyKeyboard / modifyCursorKeys / modifyFunctionKeys / modifyOtherKeys value is — the companion query for XTMODKEYS.
Byte forms
Every common string-literal form so you can paste-and-search either direction.
\x1b[?<Pp>m\033[?4m\e[?4mESC [ ? Pp m1b 5b 3f ... 6dDescription
The `?` prefix on a `m` final byte flips this from SGR (private SGR sub-modes don't exist) to XTQMODKEYS, the read-side companion of XTMODKEYS (`\x1b[><Pp>;<Pv>m`). `Pp` selects which resource to query: `0` modifyKeyboard, `1` modifyCursorKeys, `2` modifyFunctionKeys, `4` modifyOtherKeys. The reply is `\x1b[><Pp>;<Pv>m` — the **same form** as the XTMODKEYS set command, which means the terminal effectively round-trips its setting back to the caller. This is useful for libraries that want to save the current modifyKeys state before mutating it: query → mutate → restore on exit. Most CSI u protocol consumers (kitty, ghostty) also reply correctly, but their underlying keyboard model is richer than XTMODKEYS and the reply is somewhat lossy — call `\x1b[=u` (CSI u flags push) instead if you're already in CSI u land. The query is silent on `Pp` values the terminal doesn't understand — no reply at all, so wrap your read with a timeout (~50–100 ms is plenty on a Unix tty). XTQMODKEYS is one of the few xterm queries whose round-trip is purely a state read with no side effects, making it safe to interleave anywhere in a render loop.
Spec citation: xterm-ctlseqs (XTQMODKEYS)
Parameters
| Pp | Resource selector: `0` modifyKeyboard, `1` modifyCursorKeys, `2` modifyFunctionKeys, `4` modifyOtherKeys. |
Examples
printf '\033[?4m' # query modifyOtherKeys — reply: \x1b[>4;<Pv>m\n# read with: IFS= read -t 0.1 -rN 32 replyimport sys, select\nsys.stdout.write('\x1b[?4m'); sys.stdout.flush()\n# poll stdin: if select() ready in 100ms, parse \x1b[>4;<Pv>mfmt.Print("\x1b[?2m") // query modifyFunctionKeys current valueprocess.stdout.write('\x1b[?0m') // query modifyKeyboard\nprocess.stdin.once('data', buf => { /* parse reply */ })printf("\x1b[?4m"); /* before mutating modifyOtherKeys, snapshot the current value */Terminal support
- xterm
- yes
- Linux console (fbcon)
- no
- macOS Terminal.app
- no
- iTerm2
- partial
- Windows Terminal
- partial
- cmd.exe / ConPTY
- no
- kitty
- yes
- alacritty
- partial
- WezTerm
- yes
- Ghostty
- yes
- GNOME Terminal
- partial
- Konsole
- partial
- tmux
- no
- GNU screen
- no
| xterm | Linux console (fbcon) | macOS Terminal.app | iTerm2 | Windows Terminal | cmd.exe / ConPTY | kitty | alacritty | WezTerm | Ghostty | GNOME Terminal | Konsole | tmux | GNU screen |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| yes | no | no | partial | partial | no | yes | partial | yes | yes | partial | partial | no | no |