Sequence CTRL+\ is not detected in some keyboard layouts #11653

Closed
opened 2026-01-31 02:53:42 +00:00 by claunia · 15 comments
Owner

Originally created by @ojroques on GitHub (Dec 2, 2020).

Originally assigned to: @lhecker on GitHub.

Environment

Windows build number: 10.0.19041.0
Windows Terminal version (if applicable): Windows Terminal Preview v1.5.3242.0

Edit: I've updated the description.

Here is the old one.

Steps to reproduce

  1. Try to use a mapping containing CTRL+\ in an application: for instance CTRL+\ CTRL+n in Neovim to quit the built-in terminal or by adding a new mapping in tmux.

Actual behavior

Nothing happens. It seems the CTRL+\ sequence is completely ignored by Windows Terminal. I'm using WSL1 with Ubuntu 20.04 but I've tried in Powershell and same issue. I've also tried with another terminal emulator (kitty) and CTRL+\ works fine there.

I found maybe related issues: #1288, #521 but they are marked resolved and I'm still getting the bug. Any idea why?

Steps to reproduce

  1. Change your keyboard layout to the UK extended layout
  2. Launch the Terminal and run showkey -a (I'm using Ubuntu 20.04 in WSL)
  3. Press CTRL-\

Actual behavior

Nothing happens. The CTRl-\ sequence goes undetected by the terminal. I've tried different layouts (US and French) and it works fine, so this issue seems tied to the choice of the keyboard layout.

Expected behavior

CTRL-\ is correctly detected. Maybe related issues: #1288, #521.

Originally created by @ojroques on GitHub (Dec 2, 2020). Originally assigned to: @lhecker on GitHub. <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 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! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none Windows build number: 10.0.19041.0 Windows Terminal version (if applicable): Windows Terminal Preview v1.5.3242.0 ``` **Edit**: I've updated the description. <details> <summary>Here is the old one.</summary> # Steps to reproduce 1. Try to use a mapping containing `CTRL+\` in an application: for instance `CTRL+\ CTRL+n` in Neovim to quit the built-in terminal or by adding a new mapping in *tmux*. # Actual behavior Nothing happens. It seems the `CTRL+\` sequence is completely ignored by Windows Terminal. I'm using WSL1 with Ubuntu 20.04 but I've tried in Powershell and same issue. I've also tried with another terminal emulator (kitty) and `CTRL+\` works fine there. I found maybe related issues: #1288, #521 but they are marked resolved and I'm still getting the bug. Any idea why? </details> # Steps to reproduce 1. Change your keyboard layout to the [UK extended layout](https://en.wikipedia.org/wiki/QWERTY#United_Kingdom_(Extended)_Layout) 2. Launch the Terminal and run `showkey -a` (I'm using Ubuntu 20.04 in WSL) 3. Press CTRL-\ # Actual behavior Nothing happens. The CTRl-\ sequence goes undetected by the terminal. I've tried different layouts (US and French) and it works fine, so this issue seems tied to the choice of the keyboard layout. # Expected behavior CTRL-\ is correctly detected. Maybe related issues: #1288, #521.
Author
Owner

@zadjii-msft commented on GitHub (Dec 2, 2020):

What keyboard layout do you use? Is it one that has an AltGr key?

Can you share the output of running showkey -a, then pressing ctrl+\? It should look something like:
image

@zadjii-msft commented on GitHub (Dec 2, 2020): What keyboard layout do you use? Is it one that has an AltGr key? Can you share the output of running `showkey -a`, then pressing <kbd>ctrl+\\</kbd>? It should look something like: ![image](https://user-images.githubusercontent.com/18356694/100876612-3b8b5a00-346d-11eb-8ef9-7e98cd4f3b98.png)
Author
Owner

@ojroques commented on GitHub (Dec 2, 2020):

I'm using the UK extended layout so yes it has an AltGr key. I tried showkey -a but Ctrl-\ outputs nothing. Other Ctrl sequences works fine though.
Edit: I've tried with different layouts (US and UK) and it works. So it seems it is related to the UK extended layout in particular.

@ojroques commented on GitHub (Dec 2, 2020): I'm using the [UK extended layout](http://kbdlayout.info/kbdukx/) so yes it has an AltGr key. I tried `showkey -a` but `Ctrl-\` outputs nothing. Other Ctrl sequences works fine though. Edit: I've tried with different layouts (US and UK) and it works. So it seems it is related to the UK extended layout in particular.
Author
Owner

@sashkachan commented on GitHub (Dec 8, 2020):

I am having the same problem with third party Colemak layout. Can't figure out why it's not passing through. In my case, I am trying Ctrl+_ (undo in Emacs). showkey also shows no input.

@sashkachan commented on GitHub (Dec 8, 2020): I am having the same problem with third party Colemak layout. Can't figure out why it's not passing through. In my case, I am trying Ctrl+_ (undo in Emacs). showkey also shows no input.
Author
Owner

@ojroques commented on GitHub (Dec 13, 2020):

I'm aware that this isn't a high priority issue since very few users should be affected. But it's quite annoying to me because it prevents me to use some features of my editor of choice (the built-in terminal of Neovim).

I would like to take a look at the code and maybe try to find the issue myself. @zadjii-msft could you tell me where I should start looking?

@ojroques commented on GitHub (Dec 13, 2020): I'm aware that this isn't a high priority issue since very few users should be affected. But it's quite annoying to me because it prevents me to use some features of my editor of choice (the built-in terminal of Neovim). I would like to take a look at the code and maybe try to find the issue myself. @zadjii-msft could you tell me where I should start looking?
Author
Owner

@DHowett commented on GitHub (Dec 17, 2020):

The best place to start looking will be in Terminal.cpp's SendKeyEvent and SendCharEvent.

If you'd like to give us a quick debug trace, would you mind following the "input log" trace steps in this issue comment? Type out a couple Ctrl+\ sequences and send a screenshot (so we can see which records are red and which are not)

Thanks!

@DHowett commented on GitHub (Dec 17, 2020): The best place to start looking will be in Terminal.cpp's `SendKeyEvent` and `SendCharEvent`. If you'd like to give us a quick debug trace, would you mind following the "input log" trace steps in [this issue comment](https://github.com/microsoft/terminal/issues/7067#issuecomment-664670923)? Type out a couple <kbd>Ctrl+\\</kbd> sequences and send a screenshot (so we can see which records are red and which are not) Thanks!
Author
Owner

@ojroques commented on GitHub (Dec 17, 2020):

Thanks for the info I'll look into the files your mentioned.

Here's the trace of me doing CTRL+\ using the UK extended keyboard layout:
image

There seems to be no trace of the release of \. When I change my keyboard layout to US, where the sequence works fine, I get this:
image

@ojroques commented on GitHub (Dec 17, 2020): Thanks for the info I'll look into the files your mentioned. Here's the trace of me doing CTRL+\ using the UK extended keyboard layout: ![image](https://user-images.githubusercontent.com/23409060/102464990-62d94e00-404d-11eb-84bb-8305bae5ddf3.png) There seems to be no trace of the release of \\. When I change my keyboard layout to US, where the sequence works fine, I get this: ![image](https://user-images.githubusercontent.com/23409060/102466080-c9ab3700-404e-11eb-9062-efc91f4cdf8c.png)
Author
Owner

@ojroques commented on GitHub (Dec 17, 2020):

I've checked the source and it seems it's due to this particular line:
b8e6b8e27c/src/cascadia/TerminalCore/Terminal.cpp (L763) (related doc: https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-tounicodeex).

That function returns 0 meaning that the given vkey (here 220) has no associated Unicode character. And this is what we see in the screenshot when we use UK extended layout:
image

However what I don't understand is that when I switch to the standard UK layout, I see the same vkey but a different value for the unicode character:
image

I'd expect that for the same vkey + scan code we would get the same Unicode character... what is happening there?

@ojroques commented on GitHub (Dec 17, 2020): I've checked the source and it seems it's due to this particular line: https://github.com/microsoft/terminal/blob/b8e6b8e27c2c902ce18798904ce09ff32d2f68fd/src/cascadia/TerminalCore/Terminal.cpp#L763 (related doc: https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-tounicodeex). That function returns 0 meaning that the given vkey (here 220) has no associated Unicode character. And this is what we see in the screenshot when we use UK extended layout: ![image](https://user-images.githubusercontent.com/23409060/102502655-2f171c00-407f-11eb-9ed4-d3109b1f0bc8.png) However what I don't understand is that when I switch to the standard UK layout, I see the same vkey but a different value for the unicode character: ![image](https://user-images.githubusercontent.com/23409060/102502853-671e5f00-407f-11eb-9679-381bdbcb903f.png) I'd expect that for the same vkey + scan code we would get the same Unicode character... what is happening there?
Author
Owner

@zadjii-msft commented on GitHub (Jan 21, 2021):

You know, that's a good question. I don't know what's happening there. Maybe @lhecker might?

@zadjii-msft commented on GitHub (Jan 21, 2021): You know, that's a good question. I don't know what's happening there. Maybe @lhecker might?
Author
Owner

@lhecker commented on GitHub (Jan 22, 2021):

I'll look into it. 👍

@lhecker commented on GitHub (Jan 22, 2021): I'll look into it. 👍
Author
Owner

@lhecker commented on GitHub (Jan 24, 2021):

@ojroques We use ToUnicodeEx to determine whether a given key event will likely produce a character (like "a") as opposed to a control character or similar (like pressing an arrow key). This is important as the operating system knows more about the current state of the keyboard than our application and will help us to support dead keys (´+e = é for instance).

@zadjii-msft This issue occurs, because some non-US keyboard layouts apparently do not contain Ctrl-key mappings at all:
wt-issue-8458

In fact it turns out that the affected keyboards layouts don't contain any mappings for Ctrl-key combinations. It appears as if Windows simply defaults a combination of Ctrl and any A-Z key to ^A-^Z, if the current keyboard layout has no mappings itself.
AFAICS the solution is to Ctrl+key combinations in TerminalInput::HandleKey even if GetCharData is zero. PR incoming.

@lhecker commented on GitHub (Jan 24, 2021): @ojroques We use `ToUnicodeEx` to determine whether a given key event will likely produce a character (like "a") as opposed to a control character or similar (like pressing an arrow key). This is important as the operating system knows more about the current state of the keyboard than our application and will help us to support dead keys (`´+e = é` for instance). @zadjii-msft This issue occurs, because some non-US keyboard layouts apparently do not contain Ctrl-key mappings at all: ![wt-issue-8458](https://user-images.githubusercontent.com/2256941/105634204-350dd300-5e5d-11eb-8bcb-03cf50f38b5b.png) In fact it turns out that the affected keyboards layouts don't contain _any_ mappings for Ctrl-key combinations. It appears as if Windows simply defaults a combination of Ctrl and any A-Z key to ^A-^Z, if the current keyboard layout has no mappings itself. AFAICS the solution is to Ctrl+key combinations in `TerminalInput::HandleKey` even if `GetCharData` is zero. PR incoming.
Author
Owner

@DHowett commented on GitHub (Jan 28, 2021):

Triaged into 1.7 since we've got our best people looking at it. 😄

@DHowett commented on GitHub (Jan 28, 2021): Triaged into 1.7 since we've got our best people looking at it. :smile:
Author
Owner

@ghost commented on GitHub (Mar 1, 2021):

:tada:This issue was addressed in #8870, which has now been successfully released as Windows Terminal Preview v1.7.572.0.🎉

Handy links:

@ghost commented on GitHub (Mar 1, 2021): :tada:This issue was addressed in #8870, which has now been successfully released as `Windows Terminal Preview v1.7.572.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.7.572.0) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Author
Owner

@XL64 commented on GitHub (Feb 29, 2024):

I have similar issue with french layout and ctrl+_ not correctly passed to the linux applications but as it can be reproduced within any other windows terminals I tried, i guess it's more a wsl issue. I opened an issue on WSL github repo : https://github.com/microsoft/WSL/issues/11041

@XL64 commented on GitHub (Feb 29, 2024): I have similar issue with french layout and ctrl+_ not correctly passed to the linux applications but as it can be reproduced within any other windows terminals I tried, i guess it's more a wsl issue. I opened an issue on WSL github repo : https://github.com/microsoft/WSL/issues/11041
Author
Owner

@j4james commented on GitHub (Mar 1, 2024):

@XL64 That sounds like #11194, which should have been fixed in the v1.20 preview release. I've just done a test with a French keyboard layout in WSL, and Ctrl+_ is definitely working as expected for me. If you can still reproduce the issue on version 1.20, it's best you open another issue and provide more details.

@j4james commented on GitHub (Mar 1, 2024): @XL64 That sounds like #11194, which should have been fixed in the v1.20 preview release. I've just done a test with a French keyboard layout in WSL, and <kbd>Ctrl</kbd>+<kbd>_</kbd> is definitely working as expected for me. If you can still reproduce the issue on version 1.20, it's best you open another issue and provide more details.
Author
Owner

@XL64 commented on GitHub (Jun 13, 2024):

Indeed, it is fixed. what is strange is that other native windows terminal are affected too.

@XL64 commented on GitHub (Jun 13, 2024): Indeed, it is fixed. what is strange is that other native windows terminal are affected too.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#11653