Added key mappings for `[`, `]`, `,` and `\`. (#3373)

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 <mkrueger@posteo.de>
This commit is contained in:
Mike Krüger 2024-01-08 11:15:15 +01:00 committed by GitHub
parent d79fae5de1
commit 8b4c9fd374
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 0 deletions

View File

@ -1066,6 +1066,10 @@ fn key_from_key_code(key: winit::keyboard::KeyCode) -> Option<egui::Key> {
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,

View File

@ -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",