-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Virtual Keycode is incorrect on macOS non-qwerty layouts #752
Copy link
Copy link
Closed
Labels
C - in progressImplementation is proceeding smoothlyImplementation is proceeding smoothlyDS - appkitAffects the AppKit/macOS backendAffects the AppKit/macOS backendS - platform parityUnintended platform differencesUnintended platform differences
Description
The virtual_keycode field seems to be incorrect when using a non-qwerty layout. It seems to always return values corresponding to the qwerty (or perhaps physical?) layout.
I'm running the following program:
extern crate winit;
fn main() {
let mut events_loop = winit::EventsLoop::new();
let window = winit::Window::new(&events_loop).unwrap();
events_loop.run_forever(|event| {
println!("{:?}", event);
match event {
winit::Event::WindowEvent {
event: winit::WindowEvent::CloseRequested, ..
} => winit::ControlFlow::Break,
_ => winit::ControlFlow::Continue,
}
});
}
Pressing a dvorak P here (qwerty 'R') results in the following lines:
WindowEvent { window_id: WindowId(Id(140217433672064)), event: KeyboardInput { device_id: DeviceId(DeviceId), input: KeyboardInput { scancode: 15, state: Pressed, virtual_keycode: Some(R), modifiers: ModifiersState { shift: false, ctrl: false, alt: false, logo: false } } } }
WindowEvent { window_id: WindowId(Id(140217433672064)), event: ReceivedCharacter('p') }
As you can see, we receive virtual_keycode: Some(R). Also note that right after the window receives the P character. (Shouldn't these always be the same?)
The issue doesn't seem to occur on Linux/X11.
winit version: 0.18
MacBook Pro (2017)
macOS version: 10.14 (Mojave)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C - in progressImplementation is proceeding smoothlyImplementation is proceeding smoothlyDS - appkitAffects the AppKit/macOS backendAffects the AppKit/macOS backendS - platform parityUnintended platform differencesUnintended platform differences