Skip to main content
ansicode

DECSET ?1000 / ?1006 — Mouse tracking

Receive mouse click / drag / scroll events as escape sequences.

Byte forms

Every common string-literal form so you can paste-and-search either direction.

\\x1b[\x1b[?1000h (click only) \x1b[?1002h (cell drag) \x1b[?1003h (any motion) \x1b[?1006h (SGR encoding)
\\033[\033[?1000h …
\\e[\e[?1000h …
ESC [ESC [ ? <N> h / l
hex1b 5b 3f ... 68 / 6c

Description

Mouse reporting modes are stackable on/off DEC private modes. `?1000` reports button press+release, `?1002` adds drag events while a button is held, `?1003` reports every motion. The encoding sub-modes are `?1005` (UTF-8, deprecated), `?1015` (urxvt), and `?1006` (SGR — recommended, no 223-column limit, ASCII-safe). Enable `?1006` alongside `?1000`/`?1002` for portable handling. Disable everything with `?1000l ?1002l ?1003l ?1006l` on exit — a forgotten enable will spam your shell with `^[[<…` strings.

Spec citation: xterm-ctlseqs (Mouse Tracking)

Examples

bash
printf '\033[?1000h\033[?1006h'  # enable click+SGR\nprintf '\033[?1000l\033[?1006l'  # disable
python
import sys; sys.stdout.write('\x1b[?1000h\x1b[?1006h')
go
fmt.Print("\x1b[?1000h\x1b[?1006h")
javascript
process.stdout.write('\x1b[?1000h\x1b[?1006h')
c
printf("\x1b[?1000h\x1b[?1006h");

Terminal support

xterm
yes
Linux console (fbcon)
partial
macOS Terminal.app
yes
iTerm2
yes
Windows Terminal
yes
cmd.exe / ConPTY
partial
kitty
yes
alacritty
yes
WezTerm
yes
Ghostty
yes
GNOME Terminal
yes
Konsole
yes
tmux
no
GNU screen
no

Related sequences

In the family cookbook

DEC cookbook · 5. Mouse tracking — `?1000` + `?1006`