Skip to content

process send-keys arrow keys not working in application cursor key mode #51488

@liuy

Description

@liuy

Problem

Agents cannot correctly send arrow keys to background programs via process send-keys when the program uses application cursor key mode. This affects interactive CLI programs like vim, htop, and terminal games.

For example, when playing a snake.py game in a PTY session, the agent cannot control the snake's direction because arrow keys are not encoded correctly.

Programs send smkx (\x1b[?1h) to switch to application mode, expecting SS3 sequences (\x1bOA/B/C/D). But send-keys always sends CSI sequences (\x1b[A/B/C/D) which are for normal mode. Result: arrow keys don't work in application mode.

Technical Background

DECCKM (DEC Cursor Key Mode):

  • smkx (\x1b[?1h\x1b=) → application mode → SS3 sequences (\x1bOA/B/C/D)
  • rmkx (\x1b[?1l\x1b>) → normal mode → CSI sequences (\x1b[A/B/C/D)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions