You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Window: Key events never carry an uppercase letter, so a program cannot tell what the user typed #1019
Opened a window and typed Shift+a, then Shift+1, printing every Key event.
What happened
typed
Key.code of the letter or digit key
Shift+a
97 (a), after a separate Shift event (65592)
Shift+1
33 (!), after a separate Shift event (65592)
Shift+1 arrives as ! (33), but Shift+a arrives as a (97), never A (65).
Both backends drop the case on purpose:
macOS, window_open.c#L40: [ev.charactersIgnoringModifiers lowercaseString]. charactersIgnoringModifiers already applies Shift, so symbols come out shifted; lowercaseString then undoes it for letters only.
Linux, window_frame.c#L231: XLookupString runs with ShiftMask | LockMask, then 'A'..'Z' is mapped back to 'a'..'z'.
So code is neither a physical key (Shift changes 1 into !) nor the typed character (Shift does not change a into A).
A text field has to track Shift itself and rebuild the case, and Caps Lock is lost entirely.
What would help
If Key.code is meant to name the key, keeping it that way is fine. What is missing is the character the user typed.
A separate event, e.g. Text{text: String}, sent on key-down with the text the OS produces (Shift, Caps Lock and the keyboard layout applied), would cover text input without changing Key.
On macOS that is ev.characters; on Linux, the string XLookupString already returns before the case is folded.
The same event would also be the natural place for input-method text (see #1022).
Seen on Bend 2.0.5, macOS. The same code is still on main (6a77e12, v2.0.26); links point there. The Linux path was read from the source, not run.
Activity