Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On macOS, releasing a key while holding command does not send event #623

Closed
mistodon opened this issue Aug 9, 2018 · 4 comments · Fixed by #629
Closed

On macOS, releasing a key while holding command does not send event #623

mistodon opened this issue Aug 9, 2018 · 4 comments · Fixed by #629
Labels
B - bug Dang, that shouldn't have happened C - needs investigation Issue must be confirmed and researched DS - macos H - help wanted Someone please save us

Comments

@mistodon
Copy link

mistodon commented Aug 9, 2018

When I press and released a key, while holding the command key, on macOS (10.13.3) - I get the pressed event, but no corresponding released event. When not holding the command key (even if other modifier keys are held) the released event appears to fire correctly.

Steps to reproduce:

  1. Run cargo run --example window
  2. Hold the command key
  3. Press and release the H (or any other) key twice

Expected result:

There should be two released events printed to the console, in between the pressed events.

Actual result:

No release events are sent:

WindowEvent { window_id: WindowId(Id(140272942043600)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 4, state: Pressed, virtual_keycode: Some(H), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: true } } } }
WindowEvent { window_id: WindowId(Id(140272942043600)), event: ReceivedCharacter('h') }
WindowEvent { window_id: WindowId(Id(140272942043600)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 4, state: Pressed, virtual_keycode: Some(H), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: true } } } }
WindowEvent { window_id: WindowId(Id(140272942043600)), event: ReceivedCharacter('h') }

I git bisected and got dec728c as the first commit with the issue - hopefully that helps.

@felixrabe
Copy link
Contributor

I can reproduce this on macOS 10.13 with master (b2b740f) when I press "Cmd-P" (Cmd down, P down, P up, Cmd up):

WindowEvent { window_id: ..., event: KeyboardInput { device_id: ..., input: KeyboardInput { scancode: 55, state: Pressed, virtual_keycode: Some(RWin), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: true } } } }
WindowEvent { window_id: ..., event: KeyboardInput { device_id: ..., input: KeyboardInput { scancode: 35, state: Pressed, virtual_keycode: Some(P), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: true } } } }
WindowEvent { window_id: ..., event: ReceivedCharacter('p') }
WindowEvent { window_id: ..., event: KeyboardInput { device_id: ..., input: KeyboardInput { scancode: 55, state: Released, virtual_keycode: Some(RWin), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }

Which is: Cmd-pressed, P-pressed, P-received, Cmd-released.

Expected: Cmd-pressed, P-pressed, P-received, P-released, Cmd-released.

(RWin and LWin are weird too btw., especially as I'm pressing the opposite Cmd: LeftCmd = RWin and RightCmd = LWin. Separate issue.)

When I press just P (P down, P up), I get:

WindowEvent { window_id: ..., event: KeyboardInput { device_id: ..., input: KeyboardInput { scancode: 35, state: Pressed, virtual_keycode: Some(P), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }
WindowEvent { window_id: ..., event: ReceivedCharacter('p') }
WindowEvent { window_id: ..., event: KeyboardInput { device_id: ..., input: KeyboardInput { scancode: 35, state: Released, virtual_keycode: Some(P), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }

Which is as expected: P-pressed, P-received, P-released.

@francesca64 francesca64 added B - bug Dang, that shouldn't have happened H - help wanted Someone please save us DS - macos C - needs investigation Issue must be confirmed and researched labels Aug 9, 2018
@mistodon
Copy link
Author

mistodon commented Aug 9, 2018

I see the same issue with LeftCmd being RWin and vice-versa. I can open a separate issue for that if it would be helpful.

@felixrabe
Copy link
Contributor

I'm currently not working on keyboard-handling code, but when I do (maybe in a week or so), I might give this a shot.

@sodiumjoe
Copy link
Contributor

y'all mind trying this branch: #629 ?

It doesn't fix the switched Lcmd/Rwin thing, but it seems to fix the key release event. I couldn't find any adverse side effects, but any more testing would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B - bug Dang, that shouldn't have happened C - needs investigation Issue must be confirmed and researched DS - macos H - help wanted Someone please save us
Development

Successfully merging a pull request may close this issue.

4 participants