Problem
Keyboard input state is tracked per SDL keyboard, while key events are dispatched to the ViewScope of the window identified by each native event. If a key-down handler shows or focuses another application window, focus can change before the corresponding key-up. The release can then target the new window or be absent from the original window input flow, leaving the original press without a matching scoped release and potentially suppressing the next key-down.
This was observed while showing the reusable secondary window added by #405 from a Space key-down handler. That PR avoids the problem by toggling the window on Space key-up, so this is a lower-priority follow-up.
Expected behavior
A logical key press should not remain stuck or lose its release when focus moves between GameKit windows. The view that received key-down should receive either the matching key-up or a focus-loss cancellation represented consistently by the input API.
Possible direction
- record the originating
ViewScope for each pressed keyboard/scancode pair
- route a native key-up to the originating scope
- on window focus loss, synthesize releases for keys owned by that scope
- ignore a later unmatched native key-up and prevent repeat events from resurrecting a canceled press
- avoid
SDL_ResetKeyboard() because it resets keyboard state globally rather than per window
Coverage
- key-up after an internal window focus change is delivered consistently
- focus loss clears pressed state
- late native key-up does not produce a duplicate release
- repeat after focus loss does not create a new press
- keys owned by another view are unaffected
Problem
Keyboard input state is tracked per SDL keyboard, while key events are dispatched to the
ViewScopeof the window identified by each native event. If a key-down handler shows or focuses another application window, focus can change before the corresponding key-up. The release can then target the new window or be absent from the original window input flow, leaving the original press without a matching scoped release and potentially suppressing the next key-down.This was observed while showing the reusable secondary window added by #405 from a Space key-down handler. That PR avoids the problem by toggling the window on Space key-up, so this is a lower-priority follow-up.
Expected behavior
A logical key press should not remain stuck or lose its release when focus moves between GameKit windows. The view that received key-down should receive either the matching key-up or a focus-loss cancellation represented consistently by the input API.
Possible direction
ViewScopefor each pressed keyboard/scancode pairSDL_ResetKeyboard()because it resets keyboard state globally rather than per windowCoverage