Win32: VK_PACKET and VK_PROCESSKEY keydowns fire raw-key events for keys nobody pressed #182
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#182
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
The Win32 key handler (
implementations/Crafter.Graphics-Window.cpp:181-201at852ae8a) builds theKeyCodefromlParam's scan code and extended-key bit (KeyCodeFromLParam,:122) and never looks atwParam. Two kinds ofWM_KEYDOWNcarry no physical key, and both fireonRawKeyDown,onRawKeyHoldandonRawKeyUpfor whatever key theirlParamhappens to spell:VK_PACKET: input sent withSendInputandKEYEVENTF_UNICODE, which auto-type tools use for characters the layout doesn't have. ItslParamhigh word is the UTF-16 unit, not a scan code. For 'œ' (U+0153),KeyCodeFromLParamgives0x153, which isKey(CrafterKeys::Delete), soInputField_OnKeydeletes the character after the caret before theWM_CHARinserts 'œ'. '9' (U+0039) reads as Space, and ';' to 'D' as F1 to F10.VK_PROCESSKEY: a key an input method is consuming. While the Japanese IME composes, Backspace still firesonRawKeyDown(Backspace)and erases a committed character from the field, and the Enter that confirms a conversion fires the application's Enter binding.With the Unicode window class in
claude/win32-title, the text that goes with these keys now arrives intact, which makes this the next problem for IME and injected input.Found while reviewing
claude/win32-title.Suggested fix
Skip
onRawKey*andheldKeysforwParam == VK_PACKETandwParam == VK_PROCESSKEY. The text still comes throughWM_CHAR.