Skip to content

Ctrl+Backspace indistinguishable from Backspace on Windows Terminal #2139

@JosXa

Description

@JosXa

What happened?

Binding deleteWordBackward to ctrl+backspace in keybindings.json has no effect on Windows Terminal. Ctrl+Backspace deletes a single character, same as plain Backspace.

Windows Terminal sends distinct bytes for each:

  • Backspace: 0x7f
  • Ctrl+Backspace: 0x08

But both are treated as plain backspace in matchesKey() and parseKey(). So 0x08 is consumed as backspace before it can match ctrl+backspace.

Complication: 0x08 is also the ASCII code for Ctrl+H. The Emacs keybinding example uses ctrl+h for deleteCharBackward, which works because 0x08 is currently treated as backspace.

Steps to reproduce

  1. Add to ~/.pi/agent/keybindings.json:
    { "deleteWordBackward": ["ctrl+w", "alt+backspace", "ctrl+backspace"] }
  2. Open pi in Windows Terminal
  3. Type hello world
  4. Press Ctrl+Backspace
  5. Only d is deleted, not world

Verified with a raw stdin keyspy:

bytes: 0x7f  length: 1   # Backspace
bytes: 0x08  length: 1   # Ctrl+Backspace

Expected behavior

Ctrl+Backspace should be bindable as a distinct key from Backspace on terminals where they produce different bytes.

Version

0.55.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions