Skip to content

Commit

Permalink
Update lib.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
rustbasic authored Nov 24, 2024
1 parent 83a3006 commit b1745a0
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion crates/egui-winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,9 @@ impl State {
// contain some data even when the key is released.
let is_cmd = self.egui_input.modifiers.ctrl
|| self.egui_input.modifiers.command
|| self.egui_input.modifiers.mac_cmd;
|| self.egui_input.modifiers.mac_cmd
|| (self.egui_ctx.os() == egui::os::OperatingSystem::Windows
&& self.egui_input.modifiers.alt);
if pressed && !is_cmd {
self.egui_input
.events
Expand Down Expand Up @@ -1083,6 +1085,16 @@ fn key_from_named_key(named_key: winit::keyboard::NamedKey) -> Option<egui::Key>
NamedKey::Delete => Key::Delete,
NamedKey::Insert => Key::Insert,
NamedKey::Escape => Key::Escape,

NamedKey::CapsLock => Key::CapsLock,
NamedKey::NumLock => Key::NumLock,
NamedKey::ScrollLock => Key::ScrollLock,

NamedKey::Alt => Key::Alt,
NamedKey::AltGraph => Key::AltGraph,
NamedKey::Control => Key::Control,
NamedKey::Shift => Key::Shift,

NamedKey::Cut => Key::Cut,
NamedKey::Copy => Key::Copy,
NamedKey::Paste => Key::Paste,
Expand Down Expand Up @@ -1153,6 +1165,17 @@ fn key_from_key_code(key: winit::keyboard::KeyCode) -> Option<egui::Key> {
KeyCode::PageUp => Key::PageUp,
KeyCode::PageDown => Key::PageDown,

KeyCode::CapsLock => Key::CapsLock,
KeyCode::NumLock => Key::NumLock,
KeyCode::ScrollLock => Key::ScrollLock,

KeyCode::AltLeft => Key::Alt,
KeyCode::AltRight => Key::AltGraph,
KeyCode::ControlLeft => Key::Control,
KeyCode::ControlRight => Key::ControlRight,
KeyCode::ShiftLeft => Key::Shift,
KeyCode::ShiftRight => Key::ShiftRight,

// Punctuation
KeyCode::Space => Key::Space,
KeyCode::Comma => Key::Comma,
Expand Down

0 comments on commit b1745a0

Please sign in to comment.