Skip to content

Commit

Permalink
Add keys ?, /, | (#3820)
Browse files Browse the repository at this point in the history
* Part of #3653 

Also move `enum Key` to own file
  • Loading branch information
emilk authored Jan 15, 2024
1 parent c3bc4e2 commit ce6876e
Show file tree
Hide file tree
Showing 6 changed files with 536 additions and 503 deletions.
10 changes: 6 additions & 4 deletions crates/egui-winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,6 @@ fn key_from_named_key(named_key: winit::keyboard::NamedKey) -> Option<egui::Key>
Some(match named_key {
NamedKey::Enter => Key::Enter,
NamedKey::Tab => Key::Tab,
NamedKey::Space => Key::Space,
NamedKey::ArrowDown => Key::ArrowDown,
NamedKey::ArrowLeft => Key::ArrowLeft,
NamedKey::ArrowRight => Key::ArrowRight,
Expand All @@ -1012,6 +1011,9 @@ fn key_from_named_key(named_key: winit::keyboard::NamedKey) -> Option<egui::Key>
NamedKey::Cut => Key::Cut,
NamedKey::Copy => Key::Copy,
NamedKey::Paste => Key::Paste,

NamedKey::Space => Key::Space,

NamedKey::F1 => Key::F1,
NamedKey::F2 => Key::F2,
NamedKey::F3 => Key::F3,
Expand Down Expand Up @@ -1053,7 +1055,6 @@ fn key_from_key_code(key: winit::keyboard::KeyCode) -> Option<egui::Key> {
KeyCode::Tab => Key::Tab,
KeyCode::Backspace => Key::Backspace,
KeyCode::Enter | KeyCode::NumpadEnter => Key::Enter,
KeyCode::Space => Key::Space,

KeyCode::Insert => Key::Insert,
KeyCode::Delete => Key::Delete,
Expand All @@ -1062,21 +1063,22 @@ fn key_from_key_code(key: winit::keyboard::KeyCode) -> Option<egui::Key> {
KeyCode::PageUp => Key::PageUp,
KeyCode::PageDown => Key::PageDown,

// Punctuation
KeyCode::Space => Key::Space,
KeyCode::Comma => Key::Comma,
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::Slash | KeyCode::NumpadDivide => Key::Slash,
KeyCode::BracketLeft => Key::OpenBracket,
KeyCode::BracketRight => Key::CloseBracket,
KeyCode::Backquote => Key::Backtick,

KeyCode::Cut => Key::Cut,
KeyCode::Copy => Key::Copy,
KeyCode::Paste => Key::Paste,

KeyCode::Minus | KeyCode::NumpadSubtract => Key::Minus,

KeyCode::NumpadAdd => Key::Plus,
KeyCode::Equal => Key::Equals,

Expand Down
Loading

0 comments on commit ce6876e

Please sign in to comment.