microsoft/Terminal

ENHANCED_KEY flag missing when releasing RightAlt

Open

#18,120 opened on Oct 28, 2024

View on GitHub
 (1 comment) (0 reactions) (0 assignees)C++ (3,212 forks)batch import
Area-InputHelp WantedIssue-BugProduct-Terminal

Repository metrics

Stars
 (35,764 stars)
PR merge metrics
 (Avg merge 27d 19h) (24 merged PRs in 30d)

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:
#include <iostream>
#include <windows.h>
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';
        }
    }
}
  1. Press LeftCtrl key, press RightCtrl key, check ENHANCED_KEY flag.
  2. 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