Skip to content

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

Closed

Description

@mistodon

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.

Activity

  1. felixrabe commented on Aug 9, 2018

    @felixrabe
    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.

  2. added
    B - bug
    H - help wanted
    DS - appkit
    C - needs investigation
    on Aug 9, 2018
  3. mistodon commented on Aug 9, 2018

    @mistodon
    Author

    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.

  4. felixrabe commented on Aug 9, 2018

    @felixrabe
    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.

  5. sodiumjoe commented on Aug 14, 2018

    @sodiumjoe
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    B - bugC - needs investigationDS - appkitH - help wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions