Previous keystrokes modify following keystrokes #1604

Closed
opened 2026-01-30 22:31:49 +00:00 by claunia · 4 comments
Owner

Originally created by @atwok on GitHub (Jun 11, 2019).

Originally assigned to: @zadjii-msft on GitHub.

Environment

Windows build number: [run "ver" at a command prompt] 
Microsoft Windows [Version 10.0.18362.175]
Windows Terminal version (if applicable): 0.1.1502.0

Any other software?  Found using WSL, ssh to a remote server, and then emacs in terminal mode

Steps to reproduce

Alt-/ followed by Ctrl-E is sending Alt-Ctrl-E instead of just Ctrl-E. It doesn't matter if it's Ctrl-E. Ctrl-A after Alt-/ acts the same way.

showkey -a                                                                                                                                                                                                                                                              
Press any keys - Ctrl-D will terminate this program                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
^[/      27 0033 0x1b
           47 0057 0x2f
^[^E   27 0033 0x1b
             5 0005 0x05

But, for instance, Alt-A followed by Ctrl-E behaves correctly:

^[A      27 0033 0x1b
            65 0101 0x41
^E         5 0005 0x05
Originally created by @atwok on GitHub (Jun 11, 2019). Originally assigned to: @zadjii-msft on GitHub. <!-- 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. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none Windows build number: [run "ver" at a command prompt] Microsoft Windows [Version 10.0.18362.175] Windows Terminal version (if applicable): 0.1.1502.0 Any other software? Found using WSL, ssh to a remote server, and then emacs in terminal mode ``` # Steps to reproduce Alt-/ followed by Ctrl-E is sending Alt-Ctrl-E instead of just Ctrl-E. It doesn't matter if it's Ctrl-E. Ctrl-A after Alt-/ acts the same way. showkey -a Press any keys - Ctrl-D will terminate this program ^[/ 27 0033 0x1b 47 0057 0x2f ^[^E 27 0033 0x1b 5 0005 0x05 But, for instance, Alt-A followed by Ctrl-E behaves correctly: ^[A 27 0033 0x1b 65 0101 0x41 ^E 5 0005 0x05
claunia added the Resolution-Fix-CommittedIssue-BugArea-InputProduct-Conpty labels 2026-01-30 22:31:49 +00:00
Author
Owner

@DHowett-MSFT commented on GitHub (Jun 13, 2019):

Looks like this is in conpty -- PuTTY-wincon reproduces the same behavior.

@DHowett-MSFT commented on GitHub (Jun 13, 2019): Looks like this is in conpty -- PuTTY-wincon reproduces the same behavior.
Author
Owner

@zadjii-msft commented on GitHub (Jun 14, 2019):

Okay, so here's Alt+/, Ctrl+e,Alt+/, e in conpty (left) and conhost (right)

image

Good callout that it's unique to Alt+/ - here's Alt+e, Ctrl+e:
image

@zadjii-msft commented on GitHub (Jun 14, 2019): Okay, so here's `Alt+/`, `Ctrl+e`,`Alt+/`, `e` in conpty (left) and conhost (right) ![image](https://user-images.githubusercontent.com/18356694/59513838-4b7e3b00-8e81-11e9-98c3-4d60df3f2d73.png) Good callout that it's unique to `Alt+/` - here's `Alt+e`, `Ctrl+e`: ![image](https://user-images.githubusercontent.com/18356694/59513979-9730e480-8e81-11e9-939c-c6f397b2d83e.png)
Author
Owner

@zadjii-msft commented on GitHub (Jun 14, 2019):

This probably happens for any key that's not Alt+<letter>.

After the Alt+/ key is processed by conpty, the input buffer contains 5 INPUT_RECORDs:

{ keyDown:true, vkey:VK_MENU, char:0 },
{ keyDown:true, vkey:0, char:'\x1b' },
{ keyDown:true, vkey:0, char:'/' },
{ keyDown:false, vkey:0xbf, char:'/' },
{ keyDown:false, vkey:VK_MENU, char:0 }

Or actually, here's the conechokey -i output:
image

Then if you press Ctrl+E, you'll get a total:
image

The new 7 sequences suggest that we're wrapping the Ctrl+E keypress with an alt before sending it to the input buffer.

If we repeat these keypresses without the -i arg, we'll get the following:
image

Which again suggests that conpty is wrapping the ctrl+e in a pair of alts.

@zadjii-msft commented on GitHub (Jun 14, 2019): This probably happens for any key that's not `Alt+<letter>`. After the `Alt+/` key is processed by conpty, the input buffer contains 5 `INPUT_RECORD`s: ``` { keyDown:true, vkey:VK_MENU, char:0 }, { keyDown:true, vkey:0, char:'\x1b' }, { keyDown:true, vkey:0, char:'/' }, { keyDown:false, vkey:0xbf, char:'/' }, { keyDown:false, vkey:VK_MENU, char:0 } ``` Or actually, here's the `conechokey -i` output: ![image](https://user-images.githubusercontent.com/18356694/59516024-0b6d8700-8e86-11e9-9988-3b967a3830a1.png) Then if you press Ctrl+E, you'll get a total: ![image](https://user-images.githubusercontent.com/18356694/59516067-24763800-8e86-11e9-9d2f-a64e3655a3b7.png) The new 7 sequences suggest that we're wrapping the `Ctrl+E` keypress with an alt before sending it to the input buffer. If we repeat these keypresses without the `-i` arg, we'll get the following: ![image](https://user-images.githubusercontent.com/18356694/59516238-82a31b00-8e86-11e9-81db-a96904b0c306.png) Which again suggests that conpty is wrapping the `ctrl+e` in a pair of alts.
Author
Owner

@zadjii-msft commented on GitHub (Jun 14, 2019):

And the Ctrl+E keypress is being handled by InputStateMachineEngine::ActionExecuteFromEscape. That might not be right. That means we think that it should be preceeded by an alt

@zadjii-msft commented on GitHub (Jun 14, 2019): And the `Ctrl+E` keypress is being handled by `InputStateMachineEngine::ActionExecuteFromEscape`. That might not be right. That means we think that it should be preceeded by an alt
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#1604