pub struct KeyEvent {
pub key: Key,
pub modifiers: KeyModifiers,
}Expand description
A keyboard event
Fields§
§key: KeyThe key that was pressed
modifiers: KeyModifiersKey modifiers (Ctrl, Alt, Shift)
Implementations§
Source§impl KeyEvent
impl KeyEvent
Sourcepub fn new(key: Key, modifiers: KeyModifiers) -> KeyEvent
pub fn new(key: Key, modifiers: KeyModifiers) -> KeyEvent
Create a new key event
Sourcepub fn is(&self, key: Key) -> bool
pub fn is(&self, key: Key) -> bool
Check if this key event matches a specific key
§Example
if key_event.is(Key::Enter) {
// Handle enter key
}Sourcepub fn is_with_modifiers(&self, key: Key, modifiers: KeyModifiers) -> bool
pub fn is_with_modifiers(&self, key: Key, modifiers: KeyModifiers) -> bool
Check if this key event matches a specific key with modifiers
§Example
if key_event.is_with_modifiers(Key::Char('s'), KeyModifiers::CONTROL) {
// Handle Ctrl+S
}Check if this is a navigation key (arrows, home, end, page up/down)
Sourcepub fn is_function_key(&self) -> bool
pub fn is_function_key(&self) -> bool
Check if this is a function key (F1-F24)
Sourcepub fn is_media_key(&self) -> bool
pub fn is_media_key(&self) -> bool
Check if this is a media control key
Sourcepub fn has_modifiers(&self) -> bool
pub fn has_modifiers(&self) -> bool
Check if this key event has any modifiers
Sourcepub fn no_modifiers(&self) -> bool
pub fn no_modifiers(&self) -> bool
Check if this key event has no modifiers
Trait Implementations§
impl Copy for KeyEvent
impl Eq for KeyEvent
impl StructuralPartialEq for KeyEvent
Auto Trait Implementations§
impl Freeze for KeyEvent
impl RefUnwindSafe for KeyEvent
impl Send for KeyEvent
impl Sync for KeyEvent
impl Unpin for KeyEvent
impl UnwindSafe for KeyEvent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Inspectable for T
impl<T> Inspectable for T
Source§fn inspect_if(self, condition: bool, label: &str) -> Selfwhere
Self: Debug,
fn inspect_if(self, condition: bool, label: &str) -> Selfwhere
Self: Debug,
Conditionally inspect this value
Source§fn inspect_with<F>(self, label: &str, f: F) -> Self
fn inspect_with<F>(self, label: &str, f: F) -> Self
Inspect with a custom formatter