From a59eda7a272134179805c8563579eafa82e821dc Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Tue, 29 Aug 2023 14:04:12 +0200 Subject: [PATCH] egui-winit: Recognize numpad enter/plus/minus (#3285) Numpad enter should work the same as the normal return key. Numpad plus/minus should now work for scaling ui (together with cmd/ctrl) --- crates/egui-winit/src/lib.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/egui-winit/src/lib.rs b/crates/egui-winit/src/lib.rs index 15e3bb1a7..edc51b9b6 100644 --- a/crates/egui-winit/src/lib.rs +++ b/crates/egui-winit/src/lib.rs @@ -770,7 +770,7 @@ fn translate_virtual_key_code(key: winit::event::VirtualKeyCode) -> Option Key::Escape, VirtualKeyCode::Tab => Key::Tab, VirtualKeyCode::Back => Key::Backspace, - VirtualKeyCode::Return => Key::Enter, + VirtualKeyCode::Return | VirtualKeyCode::NumpadEnter => Key::Enter, VirtualKeyCode::Space => Key::Space, VirtualKeyCode::Insert => Key::Insert, @@ -780,10 +780,12 @@ fn translate_virtual_key_code(key: winit::event::VirtualKeyCode) -> Option Key::PageUp, VirtualKeyCode::PageDown => Key::PageDown, - VirtualKeyCode::Minus => Key::Minus, + VirtualKeyCode::Minus | VirtualKeyCode::NumpadSubtract => Key::Minus, // Using Mac the key with the Plus sign on it is reported as the Equals key // (with both English and Swedish keyboard). - VirtualKeyCode::Equals => Key::PlusEquals, + VirtualKeyCode::Equals | VirtualKeyCode::Plus | VirtualKeyCode::NumpadAdd => { + Key::PlusEquals + } VirtualKeyCode::Key0 | VirtualKeyCode::Numpad0 => Key::Num0, VirtualKeyCode::Key1 | VirtualKeyCode::Numpad1 => Key::Num1,