From 8b4c9fd3741ed9f2c1daaf9f4418111bf3f3f176 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Kr=C3=BCger?= Date: Mon, 8 Jan 2024 11:15:15 +0100 Subject: [PATCH] Added key mappings for `[`, `]`, `,` and `\`. (#3373) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added key mappings for '[', ']', ',' and '\'. * Closes https://github.com/emilk/egui/issues/3372 ## Added keys * egui::Key::Backslash * egui::Key::OpenBracket * egui::Key::CloseBracket * egui::Key::Comma Co-authored-by: Mike Krüger --- crates/egui-winit/src/lib.rs | 4 ++++ crates/egui/src/data/input.rs | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/crates/egui-winit/src/lib.rs b/crates/egui-winit/src/lib.rs index c7123648..44dc58e6 100644 --- a/crates/egui-winit/src/lib.rs +++ b/crates/egui-winit/src/lib.rs @@ -1066,6 +1066,10 @@ fn key_from_key_code(key: winit::keyboard::KeyCode) -> Option { KeyCode::Period => Key::Period, // KeyCode::Colon => Key::Colon, // NOTE: there is no physical colon key on an american keyboard KeyCode::Semicolon => Key::Semicolon, + KeyCode::Backslash => Key::Backslash, + KeyCode::BracketLeft => Key::OpenBracket, + KeyCode::BracketRight => Key::CloseBracket, + KeyCode::Backquote => Key::Backtick, KeyCode::Cut => Key::Cut, KeyCode::Copy => Key::Copy, diff --git a/crates/egui/src/data/input.rs b/crates/egui/src/data/input.rs index 3121d291..bcbcd6c0 100644 --- a/crates/egui/src/data/input.rs +++ b/crates/egui/src/data/input.rs @@ -962,6 +962,18 @@ pub enum Key { /// `,` Comma, + /// '/' + Backslash, + + // '[' + OpenBracket, + + // ']' + CloseBracket, + + /// '`' + Backtick, + /// `-` Minus, @@ -1094,6 +1106,10 @@ impl Key { Self::Plus, Self::Equals, Self::Semicolon, + Self::OpenBracket, + Self::CloseBracket, + Self::Backtick, + Self::Backslash, // Digits: Self::Num0, Self::Num1, @@ -1195,6 +1211,10 @@ impl Key { "Plus" | "+" => Self::Plus, "Equals" | "=" => Self::Equals, "Semicolon" | ";" => Self::Semicolon, + "Backslash" | "\\" => Self::Backslash, + "OpenBracket" | "[" => Self::OpenBracket, + "CloseBracket" | "]" => Self::CloseBracket, + "Backtick" | "`" => Self::Backtick, "0" => Self::Num0, "1" => Self::Num1, @@ -1309,6 +1329,11 @@ impl Key { Key::Equals => "Equals", Key::Semicolon => "Semicolon", + Key::Backslash => "Backslash", + Key::OpenBracket => "OpenBracket", + Key::CloseBracket => "CloseBracket", + Key::Backtick => "Backtick", + Key::Num0 => "0", Key::Num1 => "1", Key::Num2 => "2",