microsoft / microsoft/microsoft-ui-xaml
Alt key stuck in down state after Alt + Tab to app window
- Dominant language
- C++
- Stars
- 8.4k
- Forks
- 942
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 105
Description
### Describe the bug
I have a UWP app (not testing with WinAppSDK), and about 50% of the time, when I press Alt + Tab to switch to the app, the Alt key is stuck in down state, by which I mean Window.Current.CoreWindow.GetKeyState(VirtualKey.Menu) returns Down (and also input event modifiers have VirtualKeyModifiers.Menu set). This occurs until I press the Alt key. As a workaround, I am having to check the value of Window.Current.CoreWindow.GetAsyncKeyState(VirtualKey.Menu), which correctly returns None (but this is not ideal since I want the key state at the time the mouse wheel event or click occurred). Probably this is due to mismatched or out of order key down and up events being sent to the window's message queue.
### Why is this important?
Properly handle input.
### Steps to reproduce the bug
Create a UWP app, log the value of Window.Current.CoreWindow.GetKeyState(VirtualKey.Menu) on e.g. click or a timer. Note that after Alt + Tab to switch to the window, this returns Down (works 50% of the time ish).
### Actual behavior
_No response_
### Expected behavior
_No response_
### Screenshots
_No response_
### NuGet package version
None
### Windows version
Windows 11 (24H2): Build 26100
### Additional context
_No response_
Contributor guide
Research direction
No repository file or test is named. First reproduce the issue in a UWP app using Window.Current.CoreWindow.GetKeyState(VirtualKey.Menu) after Alt + Tab, and compare it with GetAsyncKeyState. Trace the input and key-state handling for mismatched Alt key events; done means the stuck state no longer occurs and the regression is covered by a test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- desktop, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100