it2 session send-key
Send a special key to a session
Synopsis
it2 session send-key [<session-id>] <key> [flags]
Description
Send a key or character to a session.
If no session-id is provided, uses $ITERM_SESSION_ID environment variable.
Supported special keys:
- Basic: enter, tab, escape, backspace, delete, space
- Arrow keys: up, down, left, right
- Navigation: home, end, pageup, pagedown
- Function keys: f1-f12
- Control keys: ctrl-a thru ctrl-z (also C-x, c-x, ^X formats)
- Meta/Alt keys: M-x, alt-x, meta-x (sends ESC+key)
- Shift combos: shift+tab, shift+up/down/left/right, shift+letter
- Complex modifiers: cmd+ctrl+shift+a, etc.
Options
-
--allow-self - Allow sending key to the same session (disabled by default for safety)
-
--confirm - Prompt for confirmation when using implicit session ID ($ITERM_SESSION_ID)
-
--dry-run - Show what would be affected without executing
-
--no-broadcast - Suppress broadcasting even if enabled
-
--scope - Filter sessions by scope (default: all sessions). Options: none, window, tab, parents, siblings, peers, lineage. Overrides IT2_SCOPE env var.
-
--stop-on-error - Stop on first error instead of continuing
Options inherited from parent commands
-
--format(default "text") - Output format (text, json, yaml) - affects how command results are displayed
-
--timeout - Timeout for API operations - how long to wait for iTerm2 to respond
-
--url - WebSocket URL for iTerm2 API - typically ws://localhost:1912 for local iTerm2
See Also
- it2 session - Manage iTerm2 sessions
Examples
# Send Enter to current session
$ it2 session send-key enter
# Send Tab to specific session
$ it2 session send-key w0t1p11:SESSION-ID tab
# Send the letter 'q'
$ it2 session send-key q
# Send Escape
$ it2 session send-key escape
# Send Ctrl+C (all formats work)
$ it2 session send-key ctrl-c
$ it2 session send-key C-c
$ it2 session send-key ^C
# Send function keys
$ it2 session send-key f5
$ it2 session send-key f12
# Send Meta/Alt combinations (Emacs-style)
$ it2 session send-key M-x
$ it2 session send-key alt-w
# Send shifted arrow keys
$ it2 session send-key shift+up
$ it2 session send-key shift+tab
# Send complex modifier combinations
$ it2 session send-key cmd+shift+z
$ it2 session send-key ctrl+alt+a