pub struct KeyboardEvent {
pub state: KeyState,
pub key: Key,
pub code: Code,
pub location: Location,
pub modifiers: Modifiers,
pub repeat: bool,
pub is_composing: bool,
}Expand description
Keyboard events are issued for all pressed and released keys.
Fields§
§state: KeyStateWhether the key is pressed or released.
key: KeyLogical key value.
code: CodePhysical key position.
location: LocationLocation for keys with multiple instances on common keyboards.
modifiers: ModifiersFlags for pressed modifier keys.
repeat: boolTrue if the key is currently auto-repeated.
is_composing: boolEvents with this flag should be ignored in a text editor and instead composition events should be used.
Implementations§
Source§impl KeyboardEvent
impl KeyboardEvent
Sourcepub fn key_down(key: impl Into<Key>, code: Code) -> KeyboardEvent
pub fn key_down(key: impl Into<Key>, code: Code) -> KeyboardEvent
Convenience constructor which takes key and code, sets state to
KeyState::Down, and sets everything else to default values.
Sourcepub fn key_up(key: impl Into<Key>, code: Code) -> KeyboardEvent
pub fn key_up(key: impl Into<Key>, code: Code) -> KeyboardEvent
Convenience constructor which takes key and code, sets state to
KeyState::Up, and sets everything else to default values.
Trait Implementations§
Source§impl Clone for KeyboardEvent
impl Clone for KeyboardEvent
Source§fn clone(&self) -> KeyboardEvent
fn clone(&self) -> KeyboardEvent
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for KeyboardEvent
impl Debug for KeyboardEvent
Source§impl Default for KeyboardEvent
impl Default for KeyboardEvent
Source§fn default() -> KeyboardEvent
fn default() -> KeyboardEvent
Returns the “default value” for a type. Read more
Source§impl Hash for KeyboardEvent
impl Hash for KeyboardEvent
Source§impl Ord for KeyboardEvent
impl Ord for KeyboardEvent
Source§fn cmp(&self, other: &KeyboardEvent) -> Ordering
fn cmp(&self, other: &KeyboardEvent) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for KeyboardEvent
impl PartialEq for KeyboardEvent
Source§impl PartialOrd for KeyboardEvent
impl PartialOrd for KeyboardEvent
impl Eq for KeyboardEvent
impl StructuralPartialEq for KeyboardEvent
Auto Trait Implementations§
impl Freeze for KeyboardEvent
impl RefUnwindSafe for KeyboardEvent
impl Send for KeyboardEvent
impl Sync for KeyboardEvent
impl Unpin for KeyboardEvent
impl UnwindSafe for KeyboardEvent
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