pub struct KeyEvent {
pub source: EventSource,
pub down: bool,
pub repeat: bool,
pub code: String,
pub modifiers: KeyModifiers,
}
Expand description
A keyboard event.
Fields§
§source: EventSource
The client identifier.
down: bool
Whether the key was pressed.
repeat: bool
Whether the event is a repeat event.
code: String
The key pressed, see the docs on JS’s KeyboardEvent.code
for details.
modifiers: KeyModifiers
The held key modifiers.
Implementations§
Source§impl KeyEvent
impl KeyEvent
Sourcepub fn direction(&self) -> Option<Direction>
pub fn direction(&self) -> Option<Direction>
The direction if either the WASD or arrow keys were pressed.
Sourcepub fn wasd_direction(&self) -> Option<Direction>
pub fn wasd_direction(&self) -> Option<Direction>
The direction if one of the WASD keys was pressed.
Sourcepub fn arrow_direction(&self) -> Option<Direction>
pub fn arrow_direction(&self) -> Option<Direction>
The direction if one of the arrow keys was pressed.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for KeyEvent
impl<'de> Deserialize<'de> for KeyEvent
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
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