Windows Terminal 1.1 breaks remapped CapsLock key inside WSL #9920

Closed
opened 2026-01-31 02:07:24 +00:00 by claunia · 5 comments
Owner

Originally created by @christianfosli on GitHub (Jul 29, 2020).

Environment

Windows build number: Microsoft Windows [Version 10.0.18363.959] (1909)
Windows Terminal version (if applicable): 1.1.2021.0

Any other software? PowerToys v0.19.2, Ubuntu 20.04 WSL fresh install from Microsoft Store with no custom config

Steps to reproduce

  • In Windows PowerToys, map "Caps Lock" key to "Ctrl" (left or right doesn't matter)
  • Open Ubuntu WSL in Windows Terminal
  • Open Vim or Neovim, go into Insert mode
  • Press "Caps Lock" (which is mapped to "Ctrl")

Expected behavior

"Caps Lock" should be treated as "Ctrl". No visible result.

Actual behavior

"Caps Lock" is treated as "Control-Space", and tries insert any previously inserted text again.


Work-Around

The issue goes away by adding this to settings.json

"experimental.input.forceVT": true,

Therefore it is likely caused by #6309

More Details, Debugging info

I originally thought it was a bug in PowerToys, but since the work-around works, I figure the bug must be here.
It's a bit annoying, because I like to escape out of normal mode in vim by pressing <CapsLock>-[ (which should be treated as <Ctrl>-[, which is again treated as <esc>). Now I instead insert the text i wrote twice.

If i input <Ctrl-V><Caps-Lock> in Vim insert mode, vim inserts <C-Space>. This is how I determined the remapped key is interpreted as <C-Space>.

  • This happens only inside Windows-Subsystem for Linux (WSL1) inside windows terminal
  • I tested with a new installation of Ubuntu from the Microsoft Store, with no customizations to Ubuntu, Vim or wslconf
  • I tested inside and outside of tmux, which did not make any difference
  • The issue is not present running WSL from CMD or Powershell, i.e. not using windows terminal.
  • The issue is not present running Neovim directly from Powershell Core inside windows terminal
  • The issue is not present running vim in Linux (tested Alpine) inside windows terminal as a Docker container
Originally created by @christianfosli on GitHub (Jul 29, 2020). # Environment ```none Windows build number: Microsoft Windows [Version 10.0.18363.959] (1909) Windows Terminal version (if applicable): 1.1.2021.0 Any other software? PowerToys v0.19.2, Ubuntu 20.04 WSL fresh install from Microsoft Store with no custom config ``` # Steps to reproduce * In Windows PowerToys, map "Caps Lock" key to "Ctrl" (left or right doesn't matter) * Open Ubuntu WSL in Windows Terminal * Open Vim or Neovim, go into Insert mode * Press "Caps Lock" (which is mapped to "Ctrl") # Expected behavior "Caps Lock" should be treated as "Ctrl". No visible result. # Actual behavior "Caps Lock" is treated as "Control-Space", and tries insert any previously inserted text again. --- ## Work-Around The issue goes away by adding this to settings.json ```json "experimental.input.forceVT": true, ``` Therefore it is likely caused by #6309 ## More Details, Debugging info I originally thought it was a bug in PowerToys, but since the work-around works, I figure the bug must be here. It's a bit annoying, because I like to escape out of normal mode in vim by pressing `<CapsLock>-[` (which should be treated as `<Ctrl>-[`, which is again treated as `<esc>`). Now I instead insert the text i wrote twice. If i input `<Ctrl-V><Caps-Lock>` in Vim insert mode, vim inserts `<C-Space>`. This is how I determined the remapped key is interpreted as `<C-Space>`. * This happens only inside Windows-Subsystem for Linux (WSL1) inside windows terminal * I tested with a new installation of Ubuntu from the Microsoft Store, with no customizations to Ubuntu, Vim or wslconf * I tested inside and outside of tmux, which did not make any difference * The issue is _not present_ running WSL from CMD or Powershell, i.e. not using windows terminal. * The issue is _not present_ running Neovim directly from Powershell Core inside windows terminal * The issue is _not present_ running vim in Linux (tested Alpine) inside windows terminal as a Docker container
claunia added the Needs-TriageResolution-Fix-CommittedNeeds-Tag-Fix labels 2026-01-31 02:07:24 +00:00
Author
Owner

@DHowett commented on GitHub (Jul 29, 2020):

So, I actually can reproduce this in WSL outside of the Terminal.

Here's the result of pressing my remapped caps lock under showkey -a to dump what the tty driver is generating:

image

This is an unfortunate casualty of the better (I know, it's ironic) keyboard support offered by #6309. There's two issues here:

  1. PowerToys' remapped key doesn't generate a "scancode" like the normal control key does
  2. WSL treats any key it receives with no character (Ctrl generates no character) plus no scancode as valid input for \0 (which roughly de-maps to Ctrl+Space, but is also the encoding for Ctrl+Shift+2)

This worked before #6309 because the remote app (here, WSL) was never made aware that somebody pressed Ctrl without a scancode.

WSL can't remove the check in (2) because it would break one of the few valid ways to insert \0. It's best fixed in PowerToys, as it's generating the key event. Once the event comes into Terminal we have no way of determining whether the user actually pressed a scancode-less key and truly wanted a null byte or whether they pressed this somewhat broken remapped Ctrl. ☹️

debugging information

real ctrl (left) key

␛[17;29;0;1;8;1_

remapped

␛[17;0;0;1;8;1_

second field is 29 in real and 0 in the remap

@DHowett commented on GitHub (Jul 29, 2020): So, I actually _can_ reproduce this in WSL outside of the Terminal. Here's the result of pressing my remapped caps lock under `showkey -a` to dump what the tty driver is generating: ![image](https://user-images.githubusercontent.com/189190/88858029-3612c000-d1ac-11ea-8859-32ac7b3d2830.png) This is an unfortunate casualty of the better (I know, it's ironic) keyboard support offered by #6309. There's two issues here: 1. PowerToys' remapped key doesn't generate a "scancode" like the normal control key does 2. WSL treats any key it receives with no character (<kbd>Ctrl</kbd> generates no character) _plus_ no scancode as valid input for `\0` (which roughly de-maps to <kbd>Ctrl+Space</kbd>, but is also the encoding for <kbd>Ctrl+Shift+2</kbd>) This worked before #6309 because the remote app (here, WSL) was never made aware that somebody pressed <kbd>Ctrl</kbd> without a scancode. WSL can't remove the check in (2) because it would break one of the few valid ways to insert `\0`. It's best fixed in _PowerToys_, as it's generating the key event. Once the event comes into Terminal we have no way of determining whether the user actually pressed a scancode-less key and truly wanted a null byte or whether they pressed this somewhat broken remapped <kbd>Ctrl</kbd>. ☹️ <details> <summary>debugging information</summary> real ctrl (left) key ``` ␛[17;29;0;1;8;1_ ``` remapped ``` ␛[17;0;0;1;8;1_ ``` second field is `29` in real and `0` in the remap </details>
Author
Owner

@christianfosli commented on GitHub (Jul 30, 2020):

Thanks, @DHowett, for finding the root cause and describing in an easy to understand way!
In this case I will close this and create an issue in PowerToys instead.

@christianfosli commented on GitHub (Jul 30, 2020): Thanks, @DHowett, for finding the root cause and describing in an easy to understand way! In this case I will close this and create an issue in PowerToys instead.
Author
Owner

@christianfosli commented on GitHub (Jul 30, 2020):

debugging information
real ctrl (left) key

␛[17;29;0;1;8;1_

remapped

␛[17;0;0;1;8;1_

second field is 29 in real and 0 in the remap

How do you find these?
If I open a new bug in PowerToys titled "Capslock -> Control map is missing "scancode".", I should probably include how to debug it properly.

@christianfosli commented on GitHub (Jul 30, 2020): > debugging information > real ctrl (left) key > > ``` > ␛[17;29;0;1;8;1_ > ``` > > remapped > > ``` > ␛[17;0;0;1;8;1_ > ``` > > second field is `29` in real and `0` in the remap How do you find these? If I open a new bug in PowerToys titled "Capslock -> Control map is missing "scancode".", I should probably include how to debug it properly.
Author
Owner

@DHowett commented on GitHub (Aug 6, 2020):

So, somebody else reported a similar bug and @lhecker investigated it pretty quickly. We think we can fix this on our side 😄 without requiring any powertoys changes.

@DHowett commented on GitHub (Aug 6, 2020): So, somebody else reported a similar bug and @lhecker investigated it pretty quickly. We think we can fix this on our side :smile: without requiring any powertoys changes.
Author
Owner

@ghost commented on GitHub (Aug 13, 2020):

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

Handy links:

@ghost commented on GitHub (Aug 13, 2020): :tada:This issue was addressed in #7145, which has now been successfully released as `Windows Terminal Preview v1.2.2234.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.2.2234.0) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#9920