Update win32-input-mode to preserve standard keys and signals #23823

Open
opened 2026-01-31 08:53:35 +00:00 by claunia · 0 comments
Owner

Originally created by @unxed on GitHub (Nov 23, 2025).

Description of the new feature

Description of the new feature / enhancement

I propose a refinement to the win32-input-mode (enabled via ^[[?9001h), originally introduced in spec 4999.

Currently, when this mode is active, all keyboard input is converted into generated CSI sequences (^[[Vk;Sc;Uc;Kd;Cs;Rc_). I request a modification (or a sub-parameter) to make this mode behave as a progressive enhancement, similar to how the kitty keyboard protocol or standard VT behavior works:

  1. Standard printable characters should remain as plain text.
  2. Standard signals (like Ctrl+C) should be sent as signals/bytes (SIGINT/\x03), not as escape sequences.
  3. Only complex keys (which cannot be represented by standard VT, e.g., Ctrl+Space, Shift+Enter, independent modifier presses, KeyUp events) should use the win32-input-mode encoding.

Why is this needed? (The "Bricked Terminal" Problem)

This request is directly motivated by the refusal of shell maintainers (specifically fish-shell) to support the current protocol.

As discussed in fish-shell issue #11877, the current "all-or-nothing" approach creates a critical reliability issue:

"It also appears to send every key in the new encoding... so if it remains turned on (e.g. because of a crash in a program that turns it on), it renders the session unusable." — @faho (fish-shell maintainer)

The Scenario:

  1. A user launches a tool that enables win32-input-mode.
  2. The tool crashes or hangs without properly disabling the mode.
  3. The user is dropped back into the shell.
  4. The terminal becomes unusable. The user cannot type reset to fix the terminal, because the shell receives complex escape sequences instead of the characters r, e, s, e, t. Even Ctrl+C is sent as a sequence, effectively preventing the user from interrupting the hung state via standard means.

Because of this risk, generic shells are unlikely to adopt win32-input-mode in its current form.

Current Adoption vs Potential

The protocol is already valuable and is used by specialized applications like:

  • far2l (Linux port of Far Manager 2)
  • turbo (TUI text editor)

However, wider adoption in the ecosystem (shells like fish, zsh, bash, and other CLI tools) depends on safety. If win32-input-mode sent standard keys as-is, it would allow shells to support rich input scenarios (like Ctrl+Alt+? or Shift+Enter bindings) without the risk of breaking the session in case of a crash.

Originally created by @unxed on GitHub (Nov 23, 2025). ### Description of the new feature ### Description of the new feature / enhancement I propose a refinement to the `win32-input-mode` (enabled via `^[[?9001h`), originally introduced in spec [4999](https://github.com/microsoft/terminal/blob/main/doc/specs/%234999%20-%20Improved%20keyboard%20handling%20in%20Conpty.md). Currently, when this mode is active, **all** keyboard input is converted into generated CSI sequences (`^[[Vk;Sc;Uc;Kd;Cs;Rc_`). I request a modification (or a sub-parameter) to make this mode behave as a **progressive enhancement**, similar to how the [kitty keyboard protocol](https://sw.kovidgoyal.net/kitty/keyboard-protocol/) or standard VT behavior works: 1. **Standard printable characters** should remain as plain text. 2. **Standard signals** (like `Ctrl+C`) should be sent as signals/bytes (`SIGINT`/`\x03`), not as escape sequences. 3. **Only complex keys** (which cannot be represented by standard VT, e.g., `Ctrl+Space`, `Shift+Enter`, independent modifier presses, KeyUp events) should use the `win32-input-mode` encoding. ### Why is this needed? (The "Bricked Terminal" Problem) This request is directly motivated by the refusal of shell maintainers (specifically **fish-shell**) to support the current protocol. As discussed in [fish-shell issue #11877](https://github.com/fish-shell/fish-shell/issues/11877), the current "all-or-nothing" approach creates a critical reliability issue: > "It also appears to send *every* key in the new encoding... so if it remains turned on (e.g. because of a crash in a program that turns it on), it renders the session unusable." — @faho (fish-shell maintainer) **The Scenario:** 1. A user launches a tool that enables `win32-input-mode`. 2. The tool crashes or hangs without properly disabling the mode. 3. The user is dropped back into the shell. 4. **The terminal becomes unusable.** The user cannot type `reset` to fix the terminal, because the shell receives complex escape sequences instead of the characters `r`, `e`, `s`, `e`, `t`. Even `Ctrl+C` is sent as a sequence, effectively preventing the user from interrupting the hung state via standard means. Because of this risk, generic shells are unlikely to adopt `win32-input-mode` in its current form. ### Current Adoption vs Potential The protocol is already valuable and is used by specialized applications like: * [far2l](https://github.com/elfmz/far2l/) (Linux port of Far Manager 2) * [turbo](https://github.com/magiblot/turbo) (TUI text editor) However, wider adoption in the ecosystem (shells like `fish`, `zsh`, `bash`, and other CLI tools) depends on safety. If `win32-input-mode` sent standard keys as-is, it would allow shells to support rich input scenarios (like `Ctrl+Alt+?` or `Shift+Enter` bindings) without the risk of breaking the session in case of a crash.
claunia added the Issue-FeatureNeeds-TriageNeeds-Tag-Fix labels 2026-01-31 08:53:35 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#23823