pub trait EguiEventExt: Sealed {
// Required method
fn to_hotkey(&self) -> Option<Hotkey>;
}Expand description
Convert an egui::Event keyboard event to a kbd Hotkey.
Returns None if the event is not a keyboard event, or if the key
has no kbd equivalent.
Only Event::Key { .. } variants produce a hotkey. All other event
variants return None.
This trait is sealed and cannot be implemented outside this crate.
Required Methods§
Sourcefn to_hotkey(&self) -> Option<Hotkey>
fn to_hotkey(&self) -> Option<Hotkey>
Convert this event to a Hotkey, or None if not a keyboard event.
§Examples
use egui::{Key as EguiKey, Modifiers};
use kbd::prelude::*;
use kbd_egui::EguiEventExt;
let event = egui::Event::Key {
key: EguiKey::S,
physical_key: None,
pressed: true,
repeat: false,
modifiers: Modifiers::CTRL,
};
assert_eq!(
event.to_hotkey(),
Some(Hotkey::new(Key::S).modifier(Modifier::Ctrl)),
);