Skip to content

Commit

Permalink
Added key mappings for '[', ']', ',' and '\'.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Krüger committed Sep 23, 2023
1 parent 33a0f50 commit 39cc3ba
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Changes since the last release can be found by running the `scripts/generate_cha
* Plot widget - allow disabling zoom and drag for x and y separately [#2901](https://github.com/emilk/egui/pull/2901) (thanks [@OmegaJak](https://github.com/OmegaJak)!)
* Add character limit to `TextEdit` [#2816](https://github.com/emilk/egui/pull/2816) (thanks [@wzid](https://github.com/wzid)!)
* Add `egui::Modifiers::contains` [#2989](https://github.com/emilk/egui/pull/2989) (thanks [@Wumpf](https://github.com/Wumpf)!)

* Added Key::Backslash, Key::OpenBracket, Key::CloseBracket, Key::Comma
### 🔧 Changed
* Improve vertical alignment of fonts [#2724](https://github.com/emilk/egui/pull/2724) (thanks [@lictex](https://github.com/lictex)!)
* Transpose the value/satuation panel of the color picker [#2727](https://github.com/emilk/egui/pull/2727) (thanks [@IVAN-MK7](https://github.com/IVAN-MK7)!)
Expand Down
5 changes: 5 additions & 0 deletions crates/eframe/src/web/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ pub fn translate_key(key: &str) -> Option<egui::Key> {
"-" => Some(Key::Minus),
"+" | "=" => Some(Key::PlusEquals),

"\\" => Some(Key::Backslash),
"[" => Some(Key::OpenBracket),
"]" => Some(Key::CloseBracket),
"," => Some(Key::Comma),

"0" => Some(Key::Num0),
"1" => Some(Key::Num1),
"2" => Some(Key::Num2),
Expand Down
5 changes: 5 additions & 0 deletions crates/egui-winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,11 @@ fn translate_virtual_key_code(key: winit::event::VirtualKeyCode) -> Option<egui:
VirtualKeyCode::PageUp => Key::PageUp,
VirtualKeyCode::PageDown => Key::PageDown,

VirtualKeyCode::Backslash => Key::Backslash,
VirtualKeyCode::LBracket => Key::OpenBracket,
VirtualKeyCode::RBracket => Key::CloseBracket,
VirtualKeyCode::Comma => Key::Comma,

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).
Expand Down
9 changes: 9 additions & 0 deletions crates/egui/src/data/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,11 @@ pub enum Key {
PageUp,
PageDown,

Backslash,
OpenBracket,
CloseBracket,
Comma,

/// The virtual keycode for the Minus key.
Minus,

Expand Down Expand Up @@ -817,6 +822,10 @@ impl Key {
Key::PageDown => "PageDown",
Key::Minus => "Minus",
Key::PlusEquals => "Plus",
Key::Backslash => "\\",
Key::OpenBracket => "[",
Key::CloseBracket => "]",
Key::Comma => ",",
Key::Num0 => "0",
Key::Num1 => "1",
Key::Num2 => "2",
Expand Down

0 comments on commit 39cc3ba

Please sign in to comment.