Skip to content

Commit

Permalink
Added key mappings for [, ], , and \. (#3373)
Browse files Browse the repository at this point in the history
Added key mappings for '[', ']', ',' and '\'.

* Closes #3372

## Added keys

* egui::Key::Backslash
* egui::Key::OpenBracket
* egui::Key::CloseBracket
* egui::Key::Comma

Co-authored-by: Mike Krüger <[email protected]>
  • Loading branch information
mkrueger and mkrueger authored Jan 8, 2024
1 parent d79fae5 commit 8b4c9fd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/egui-winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
25 changes: 25 additions & 0 deletions crates/egui/src/data/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,18 @@ pub enum Key {
/// `,`
Comma,

/// '/'
Backslash,

// '['
OpenBracket,

// ']'
CloseBracket,

/// '`'
Backtick,

/// `-`
Minus,

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 8b4c9fd

Please sign in to comment.