Win32: keys stay in heldKeys after the window loses the keyboard #180
Labels
No labels
claude:blocked
claude:done
claude:failed
claude:in-progress
claude:ready
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Catcrafts/Crafter.Graphics#180
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
On Win32 nothing empties
Window::heldKeyswhen the window loses the keyboard. A key held while the user Alt+Tabs away, or clicks another window, stays inheldKeys, because itsWM_KEYUPgoes to the window that has the focus by then. Line numbers refer to852ae8a.heldKeysis written only by theWM_KEYDOWN/WM_SYSKEYDOWNandWM_KEYUP/WM_SYSKEYUPcases (implementations/Crafter.Graphics-Window.cpp:189,:198).WndProchas noWM_KILLFOCUSorWM_ACTIVATEcase.wl_keyboard.leave(implementations/Crafter.Graphics-Device.cpp:582).Inputreads it on every tick (implementations/Crafter.Graphics-Input.cpp:53,:98-101).So: hold W, Alt+Tab away, release both keys in the other window. W and Alt stay in
heldKeys, and everyKeyBindorWASDBindon them reads as held, in the background and after the window comes back, until each key is pressed and released in this window again.Found while reviewing
claude/win32-title.Suggested fix
Handle
WM_KILLFOCUS: clearheldKeys, as Wayland's leave does (or fireonRawKeyUpfor each key first, if the backends should agree on that), and pass the message on toDefWindowProc. A Win32 test can postWM_KEYDOWN, thenWM_KILLFOCUS, and expectheldKeysempty.