diff --git a/core/src/keyboard/event.rs b/core/src/keyboard/event.rs index 88c57b2199..8a8b45c436 100644 --- a/core/src/keyboard/event.rs +++ b/core/src/keyboard/event.rs @@ -12,12 +12,15 @@ use crate::keyboard::{Key, Location, Modifiers}; pub enum Event { /// A keyboard key was pressed. KeyPressed { - /// The key pressed. + /// The key pressed. Tries to meet expectations, currently equal to `modified_key`. key: Key, /// The key pressed with all keyboard modifiers applied, except Ctrl. modified_key: Key, + /// The key on keyboard layer 0 pressed. + baselayer_key: Key, + /// The physical key pressed. physical_key: key::Physical, @@ -33,12 +36,15 @@ pub enum Event { /// A keyboard key was released. KeyReleased { - /// The key released. + /// The key released. Tries to meet expectations, currently equal to `modified_key`. key: Key, /// The key released with all keyboard modifiers applied, except Ctrl. modified_key: Key, + /// The key on keyboard layer 0 released. + baselayer_key: Key, + /// The physical key released. physical_key: key::Physical, diff --git a/test/src/simulator.rs b/test/src/simulator.rs index b0a9a5d171..2c642983ee 100644 --- a/test/src/simulator.rs +++ b/test/src/simulator.rs @@ -375,7 +375,8 @@ pub fn press_key( Event::Keyboard(keyboard::Event::KeyPressed { key: key.clone(), - modified_key: key, + modified_key: key.clone(), + baselayer_key: key, physical_key: keyboard::key::Physical::Unidentified( keyboard::key::NativeCode::Unidentified, ), @@ -391,7 +392,8 @@ pub fn release_key(key: impl Into) -> Event { Event::Keyboard(keyboard::Event::KeyReleased { key: key.clone(), - modified_key: key, + modified_key: key.clone(), + baselayer_key: key, physical_key: keyboard::key::Physical::Unidentified( keyboard::key::NativeCode::Unidentified, ), diff --git a/winit/src/conversion.rs b/winit/src/conversion.rs index 250918ab78..e10a1276ee 100644 --- a/winit/src/conversion.rs +++ b/winit/src/conversion.rs @@ -204,7 +204,7 @@ pub fn window_event( // Ignore keyboard presses/releases during window focus/unfocus WindowEvent::KeyboardInput { is_synthetic, .. } if is_synthetic => None, WindowEvent::KeyboardInput { event, .. } => Some(Event::Keyboard({ - let key = { + let baselayer_key = { #[cfg(not(target_arch = "wasm32"))] { use winit::platform::modifier_supplement::KeyEventExtModifierSupplement; @@ -242,8 +242,9 @@ pub fn window_event( .. } = event; - let key = self::key(key); let modified_key = self::key(logical_key); + let key = modified_key.clone(); + let baselayer_key = self::key(baselayer_key); let physical_key = self::physical_key(physical_key); let modifiers = self::modifiers(modifiers); @@ -265,6 +266,7 @@ pub fn window_event( keyboard::Event::KeyPressed { key, modified_key, + baselayer_key, physical_key, modifiers, location, @@ -275,6 +277,7 @@ pub fn window_event( keyboard::Event::KeyReleased { key, modified_key, + baselayer_key, physical_key, modifiers, location,