microsoft / microsoft/terminal

ENHANCED_KEY flag missing when releasing RightAlt

Open
#18,120 1 comment 0 reactions 0 assignees View on GitHub
Area-Input Help Wanted Issue-Bug Product-Terminal
Dominant language
C++
Stars
105k
Forks
9.6k
Avg merge
3d 17h
Merged PRs (30d)
29

Description

### Windows Terminal version

current main

### Windows build number

10.0.19045.4894

### Other Software

_No response_

### Steps to reproduce

1. Run the following c++ code:
```c++
#include
#include
int main()
{
INPUT_RECORD rec;
DWORD count;
while (true)
{
::ReadConsoleInputW(::GetStdHandle(STD_INPUT_HANDLE), &rec, 1, &count);
if (rec.EventType == KEY_EVENT)
{
std::cout << "type: KEY_EVENT" << std::hex
<< ", down: " << rec.Event.KeyEvent.bKeyDown
<< ", ENHANCED_KEY: " << !!(rec.Event.KeyEvent.dwControlKeyState & ENHANCED_KEY)
<< ", ctrl: 0x" << rec.Event.KeyEvent.dwControlKeyState
<< ", vcod: 0x" << rec.Event.KeyEvent.wVirtualKeyCode
<< ", scod: 0x" << rec.Event.KeyEvent.wVirtualScanCode
<< ", wchr: 0x" << rec.Event.KeyEvent.uChar.UnicodeChar << '\n';
}
}
}
```
2. Press LeftCtrl key, press RightCtrl key, check ENHANCED_KEY flag.
3. Press LeftAlt key, press RightAlt key, check ENHANCED_KEY flag.

### Expected Behavior

The ENHANCED_KEY flag is present when RightAlt is pressed and released.

The current conhost.exe is not affected by this issue.

### Actual Behavior

The ENHANCED_KEY flag is absent when RightAlt is released, but is present when RightAlt is pressed.

Contributor guide

Open the contributing guide

Research direction

Start by tracing Windows Terminal's handling of KEY_EVENT records and the ENHANCED_KEY state for RightAlt, using the provided ReadConsoleInputW reproduction program. Compare the release event with conhost.exe behavior; done means ENHANCED_KEY is present when RightAlt is both pressed and released.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
cli, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.