Winit: Redundant ReceivedCharacter after arrow key and F key on macOS

Created on 27 Jan 2019  路  2Comments  路  Source: rust-windowing/winit

When you enter the arrow keys and F keys on a Mac, there will be redundant ReceivedCharacter events compared to Linux and Windows.

For example, you can start the window with cargo run --example window on the Mac, and press Left Arrow key, you will see the redundant ReceivedCharacter event, which does not happen on Linux and Windows.

Here are some logs.

WindowEvent { window_id: WindowId(Id(140334732557360)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 124, state: Pressed, virtual_keycode: Some(Right), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }
WindowEvent { window_id: WindowId(Id(140334732557360)), event: ReceivedCharacter('\u{f703}') }
WindowEvent { window_id: WindowId(Id(140334732557360)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 124, state: Released, virtual_keycode: Some(Right), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }
macOS bug

Most helpful comment

macOS generates unicode corporate-zone characters for various non-printable key presses (F1..., insert/delete, arrows, scroll lock, etc) within the NSResponder - (void)keyDown:(NSEvent *)event message.

Other OS's don't generate characters for these keypresses.

The question to the winit library authors is this: who is responsible for stripping these characters? The winit libray? Or clients of the winit library?

I'm prepared to submit a PR against winit if the desire is to offer clients more uniform keyboard events.

All 2 comments

macOS generates unicode corporate-zone characters for various non-printable key presses (F1..., insert/delete, arrows, scroll lock, etc) within the NSResponder - (void)keyDown:(NSEvent *)event message.

Other OS's don't generate characters for these keypresses.

The question to the winit library authors is this: who is responsible for stripping these characters? The winit libray? Or clients of the winit library?

I'm prepared to submit a PR against winit if the desire is to offer clients more uniform keyboard events.

Any updates on this?

Was this page helpful?
0 / 5 - 0 ratings