Send different key codes for Tab and Ctrl+I (READ: support modifyOtherKeys) #18221

Open
opened 2026-01-31 06:07:19 +00:00 by claunia · 6 comments
Owner

Originally created by @ghillb on GitHub (Aug 20, 2022).

Description of the new feature/enhancement

When using ms-terminal, Tab and Ctrl+I send the same key codes. This makes it impossible to map them differently, for example in vim or nvim (which support this functionality: https://github.com/neovim/neovim/pull/17932#issue-1188088238).

If ms-terminal sent different key codes (like for example kitty or alacritty terminal), then it would be possible to map these keys to different functionalities in software running inside the terminal. This would enhance user experience and make it easier to migrate from the aforementioned terminals.

Proposed technical implementation details (optional)

Originally created by @ghillb on GitHub (Aug 20, 2022). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> # Description of the new feature/enhancement When using ms-terminal, `Tab` and `Ctrl+I` send the same key codes. This makes it impossible to map them differently, for example in vim or nvim (which support this functionality: https://github.com/neovim/neovim/pull/17932#issue-1188088238). If ms-terminal sent different key codes (like for example kitty or alacritty terminal), then it would be possible to map these keys to different functionalities in software running inside the terminal. This would enhance user experience and make it easier to migrate from the aforementioned terminals. <!-- A clear and concise description of what the problem is that the new feature would solve. Describe why and how a user would use this new functionality (if applicable). --> # Proposed technical implementation details (optional) <!-- A clear and concise description of what you want to happen. -->
Author
Owner

@zadjii-msft commented on GitHub (Aug 22, 2022):

Okay this sounds like we just need to support modifyOtherKeys. There was previous discussion in

From the docs

When modifyOtherKeys is set, ordinary keys may be sent as escape
sequences:

  • When modifyOtherKeys is set to 1, only the alt- and meta-modifiers
    apply. For example, alt-Tab sends CSI 2 7 ; 3 ; 9 ~ (the second
    parameter is "3" for alt, and the third parameter is the ASCII value
    of tab, "9").
  • When modifyOtherKeys is set to 2, all of the modifiers apply. For
    example, shift-Tab sends CSI 2 7 ; 2 ; 9 ~ rather than CSI Z (the
    second parameter is "2" for shift).
@zadjii-msft commented on GitHub (Aug 22, 2022): Okay this sounds like we just need to support `modifyOtherKeys`. There was previous discussion in * #8719 * #11509 From the docs > When [modifyOtherKeys](https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys) is set, ordinary keys may be sent as escape > sequences: > * When [modifyOtherKeys](https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys) is set to 1, only the alt- and meta-modifiers > apply. For example, alt-Tab sends `CSI 2 7 ; 3 ; 9 ~` (the second > parameter is "3" for alt, and the third parameter is the ASCII value > of tab, "9"). > * When [modifyOtherKeys](https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:modifyOtherKeys) is set to 2, all of the modifiers apply. For > example, shift-Tab sends `CSI 2 7 ; 2 ; 9 ~` rather than `CSI Z` (the > second parameter is "2" for shift).
Author
Owner

@matthewgrossman commented on GitHub (Oct 30, 2022):

Does anyone have a workaround for this problem in the interim?

My concrete issue: I have different mappings for <TAB> and <C-i> in neovim. In macOS, Kitty can differentiate just fine, but in Terminal on Windows (ubuntu wsl2) it seems to view them as the same input.

@matthewgrossman commented on GitHub (Oct 30, 2022): Does anyone have a workaround for this problem in the interim? My concrete issue: I have different mappings for `<TAB>` and `<C-i>` in neovim. In macOS, Kitty can differentiate just fine, but in Terminal on Windows (ubuntu wsl2) it seems to view them as the same input.
Author
Owner

@AH-Merii commented on GitHub (Jan 25, 2024):

Hi @zadjii-msft,

As the comment above mentioned, is there a temporary workaround that we can use while this issue is being worked on?

@AH-Merii commented on GitHub (Jan 25, 2024): Hi @zadjii-msft, As the comment above mentioned, is there a temporary workaround that we can use while this issue is being worked on?
Author
Owner

@zadjii-msft commented on GitHub (Jan 25, 2024):

You could probably manually add a sendInput action in the Terminal settings, bound to ctrl+I, that sends ~ some escape sequence ~, and then configure your editor to be bound to that escape sequence instead of just C-i.

What ~ some escape sequence ~ actually is would depend on the rest of your config, I'd reckon. I'm not super familiar with keybinding editing for neovim, so I don't really have a good end-to-end recommendation here, I'm afraid.

@zadjii-msft commented on GitHub (Jan 25, 2024): You could probably manually add a `sendInput` action in the Terminal settings, bound to `ctrl+I`, that sends ~ some escape sequence ~, and then configure your editor to be bound to that escape sequence instead of just `C-i`. What ~ some escape sequence ~ actually is would depend on the rest of your config, I'd reckon. I'm not super familiar with keybinding editing for neovim, so I don't really have a good end-to-end recommendation here, I'm afraid.
Author
Owner

@AH-Merii commented on GitHub (Jan 25, 2024):

No worries, thanks for pointing me in the right direction, I will look into it!

@AH-Merii commented on GitHub (Jan 25, 2024): No worries, thanks for pointing me in the right direction, I will look into it!
Author
Owner

@AntonC9018 commented on GitHub (Mar 2, 2024):

It doesn't work by default for me on alacritty. In fact, it straight up ignores those key combos altogether.

If anyone has a working hack to fix this, making all of these keys be sent correctly, please share. It's a really draining issue for me

@AntonC9018 commented on GitHub (Mar 2, 2024): It doesn't work by default for me on alacritty. In fact, it straight up ignores those key combos altogether. If anyone has a working hack to fix this, making all of these keys be sent correctly, please share. It's a really draining issue for me
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#18221