Skip to content

best-effort reconciliation of modifier key states from winit#24845

Open
robtfm wants to merge 1 commit into
bevyengine:mainfrom
robtfm:modifiers-reconcile
Open

best-effort reconciliation of modifier key states from winit#24845
robtfm wants to merge 1 commit into
bevyengine:mainfrom
robtfm:modifiers-reconcile

Conversation

@robtfm

@robtfm robtfm commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Objective

in some circumstances modifier key events can be swallowed by the OS and lost to the application (e.g. macos screencap key chords like super+shift+5, potentially windows gamebar chord win+g). winit updates modifier state on any relevant event and provides an event stream, but bevy does not currently use those events.

Solution

add a reconciliation vs winit's modifier events

all platforms:

  • when winit declares a logical modifier is unpressed (e.g. Alt), force all the relevant keycodes (e.g. AltLeft) to unpressed. prevents "sticky modifiers" that are not caught by the blanket focus-lost clear.

macos native only (relying on keycode press state, which is only reported accurately on macos currently, but could be supported on windows if winit extends support):

  • when winit declares a physical modifier is unpressed[1], force that keycode to unpressed. catches the rare case where both shifts are held and one release is swallowed.
  • when winit declares a physical modifier is pressed, set the relevant key as pressed. effectively sets modifiers that are held when focus is gained.

[1]winit reports only "pressed" or "unknown". to tell if a key is declared unpressed, we check if it is "unknown" and another key in the group is "pressed"

Testing

tested with https://github.com/robtfm/modifier-test-app (on macos native and wasm).

@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior A-Windowing Platform-agnostic interface layer to run your app in S-Needs-Review Needs reviewer attention (from anyone!) to move forward A-Input Player input via keyboard, mouse, gamepad, and more labels Jul 5, 2026
@github-project-automation github-project-automation Bot moved this to Needs SME Triage in Input Jul 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Input Player input via keyboard, mouse, gamepad, and more A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

Status: Needs SME Triage

Development

Successfully merging this pull request may close these issues.

2 participants