#[non_exhaustive]pub struct KeyEvent {
pub code: KeyCode,
pub modifiers: KeyModifiers,
pub kind: KeyEventKind,
pub location: KeyLocation,
}Expand description
Keyboard input event.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.code: KeyCodeThe key code.
modifiers: KeyModifiersModifiers held down during the event.
kind: KeyEventKindWhether this is a press, auto-repeat, or release.
Backends that cannot distinguish these always report
KeyEventKind::Press. See KeyEventKind for per-backend behavior.
location: KeyLocationThe physical location of the key, for keys that appear in more than one place.
Backends that cannot determine this always report KeyLocation::Standard.
Implementations§
Source§impl KeyEvent
impl KeyEvent
Sourcepub const fn new(code: KeyCode, modifiers: KeyModifiers) -> Self
pub const fn new(code: KeyCode, modifiers: KeyModifiers) -> Self
Creates a key press event with the given code and modifiers, and
KeyLocation::Standard.
Sourcepub const fn with_kind(
code: KeyCode,
modifiers: KeyModifiers,
kind: KeyEventKind,
) -> Self
pub const fn with_kind( code: KeyCode, modifiers: KeyModifiers, kind: KeyEventKind, ) -> Self
Creates a key event with an explicit KeyEventKind and KeyLocation::Standard.
Sourcepub const fn with_location(
code: KeyCode,
modifiers: KeyModifiers,
kind: KeyEventKind,
location: KeyLocation,
) -> Self
pub const fn with_location( code: KeyCode, modifiers: KeyModifiers, kind: KeyEventKind, location: KeyLocation, ) -> Self
Creates a key event with an explicit KeyEventKind and KeyLocation.
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 UnsafeUnpin 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,
§impl<C> WithAlpha for Cwhere
C: Copy,
impl<C> WithAlpha for Cwhere
C: Copy,
§fn with_alpha_first<A>(self, alpha: A) -> AlphaFirst<A, Self>
fn with_alpha_first<A>(self, alpha: A) -> AlphaFirst<A, Self>
Wraps
self with alpha, storing alpha before the color in memory
(see [AlphaFirst]).§fn with_alpha_last<A>(self, alpha: A) -> AlphaLast<A, Self>
fn with_alpha_last<A>(self, alpha: A) -> AlphaLast<A, Self>
Wraps
self with alpha, storing alpha after the color in memory
(see [AlphaLast]).