Incorrect keycode for "CTRL+H" in Windows Terminal #8210

Open
opened 2026-01-31 01:23:32 +00:00 by claunia · 0 comments
Owner

Originally created by @skywind3000 on GitHub (May 18, 2020).

Environment

Windows: 
Platform ServicePack Version      VersionString
-------- ----------- -------      -------------
 Win32NT             10.0.18363.0 Microsoft Windows NT 10.0.18363.0

Vim.exe: 8.2.701

Steps to reproduce

  1. start "cmd.exe" in windows terminal.
  2. run vim.exe (https://github.com/vim/vim-win32-installer/releases)
  3. input "iaaaaaaa" to enter insert mode and append some characters.
  4. press "CTRL+h" several times

Expected behavior

The previous "aaaaa" should get deleted (CTRL+H in vim's insert mode will delete previous character), just like running vim.exe in the traditional cmd.exe window.

Actual behavior

图片

"CTRL+h" inserts some strange characters: "ÎzÎzÎzÎzÎzÎzÎz"

after some inspection, I located the difference, if I use getch in msvcrt.dll to display keycode:

  1. Run cmd.exe directly:
D:\>python -c "import msvcrt;print(msvcrt.getch())"
b'\x08'                   <--- press CTRL+H

D:\>python -c "import msvcrt;print(msvcrt.getch())"
b'\x08'                   <--- press BackSpace

Both "CTRL+H" and "BackSpace" are b'\x08', vim.exe works fine with it .

  1. Run cmd.exe in Windows Terminal:
D:\>python -c "import msvcrt;print(msvcrt.getch())"
b'\x7f'                   <--- press CTRL+H

D:\>python -c "import msvcrt;print(msvcrt.getch())"
b'\x08'                   <--- press BackSpace

Now, "CTRL+H" becomes b'\x7f' in Windows Terminal, which is different from running cmd.exe directly without windows terminal, and that difference breaks some terminal softwares like vim.exe .

Originally created by @skywind3000 on GitHub (May 18, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 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: Platform ServicePack Version VersionString -------- ----------- ------- ------------- Win32NT 10.0.18363.0 Microsoft Windows NT 10.0.18363.0 Vim.exe: 8.2.701 ``` # Steps to reproduce <!-- A description of how to trigger this bug. --> 1. start "cmd.exe" in windows terminal. 2. run vim.exe (https://github.com/vim/vim-win32-installer/releases) 3. input "iaaaaaaa" to enter insert mode and append some characters. 4. press "CTRL+h" several times # Expected behavior <!-- A description of what you're expecting, possibly containing screenshots or reference material. --> The previous "aaaaa" should get deleted (CTRL+H in vim's insert mode will delete previous character), just like running vim.exe in the traditional `cmd.exe` window. # Actual behavior <!-- What's actually happening? --> ![图片](https://user-images.githubusercontent.com/3035071/82171493-12084800-98fa-11ea-97e8-a9eca3c77df9.png) "CTRL+h" inserts some strange characters: "ÎzÎzÎzÎzÎzÎzÎz" after some inspection, I located the difference, if I use `getch` in `msvcrt.dll` to display keycode: 1. Run cmd.exe directly: ```none D:\>python -c "import msvcrt;print(msvcrt.getch())" b'\x08' <--- press CTRL+H D:\>python -c "import msvcrt;print(msvcrt.getch())" b'\x08' <--- press BackSpace ``` Both "CTRL+H" and "BackSpace" are `b'\x08'`, vim.exe works fine with it . 2. Run cmd.exe in Windows Terminal: ```none D:\>python -c "import msvcrt;print(msvcrt.getch())" b'\x7f' <--- press CTRL+H D:\>python -c "import msvcrt;print(msvcrt.getch())" b'\x08' <--- press BackSpace ``` Now, "CTRL+H" becomes `b'\x7f'` in Windows Terminal, which is different from running cmd.exe directly without windows terminal, and that difference breaks some terminal softwares like vim.exe .
claunia added the Issue-BugArea-InputNeeds-Tag-FixProduct-ConptyPriority-2 labels 2026-01-31 01:23:33 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#8210