diff --git a/src/changelog/unreleased.md b/src/changelog/unreleased.md index 4e91f91773..20d3a7c6d7 100644 --- a/src/changelog/unreleased.md +++ b/src/changelog/unreleased.md @@ -75,6 +75,7 @@ changelog entry. variables to test the respective modifiers of window creation. - Added `Window::surface_position`, which is the position of the surface inside the window. - Added `Window::safe_area`, which describes the area of the surface that is unobstructed. +- On Windows, improved scancode conversions for more obscure key codes. ### Changed diff --git a/src/platform_impl/windows/keyboard.rs b/src/platform_impl/windows/keyboard.rs index d360a1d363..d4e7cc3407 100644 --- a/src/platform_impl/windows/keyboard.rs +++ b/src/platform_impl/windows/keyboard.rs @@ -1079,6 +1079,20 @@ pub(crate) fn physicalkey_to_scancode(physical_key: PhysicalKey) -> Option KeyCode::AudioVolumeDown => Some(0xe02e), KeyCode::AudioVolumeMute => Some(0xe020), KeyCode::AudioVolumeUp => Some(0xe030), + + // Extra from Chromium sources: + // https://chromium.googlesource.com/chromium/src.git/+/3e1a26c44c024d97dc9a4c09bbc6a2365398ca2c/ui/events/keycodes/dom/dom_code_data.inc + KeyCode::Lang4 => Some(0x0077), + KeyCode::Lang3 => Some(0x0078), + KeyCode::Undo => Some(0xe008), + KeyCode::Paste => Some(0xe00a), + KeyCode::Cut => Some(0xe017), + KeyCode::Copy => Some(0xe018), + KeyCode::Eject => Some(0xe02c), + KeyCode::Help => Some(0xe03b), + KeyCode::Sleep => Some(0xe05f), + KeyCode::WakeUp => Some(0xe063), + _ => None, } } @@ -1238,6 +1252,20 @@ pub(crate) fn scancode_to_physicalkey(scancode: u32) -> PhysicalKey { 0xe02e => KeyCode::AudioVolumeDown, 0xe020 => KeyCode::AudioVolumeMute, 0xe030 => KeyCode::AudioVolumeUp, + + // Extra from Chromium sources: + // https://chromium.googlesource.com/chromium/src.git/+/3e1a26c44c024d97dc9a4c09bbc6a2365398ca2c/ui/events/keycodes/dom/dom_code_data.inc + 0x0077 => KeyCode::Lang4, + 0x0078 => KeyCode::Lang3, + 0xe008 => KeyCode::Undo, + 0xe00a => KeyCode::Paste, + 0xe017 => KeyCode::Cut, + 0xe018 => KeyCode::Copy, + 0xe02c => KeyCode::Eject, + 0xe03b => KeyCode::Help, + 0xe05f => KeyCode::Sleep, + 0xe063 => KeyCode::WakeUp, + _ => return PhysicalKey::Unidentified(NativeKeyCode::Windows(scancode as u16)), }) }