pub struct KeyboardEvent {
pub key: KeyCode,
pub state: ButtonState,
pub modifiers: Modifiers,
pub text: Option<String>,
pub timestamp: Instant,
}Expand description
Keyboard key press or release event.
Chrome equivalent: WebKeyboardEvent.
§Fields
-
key: Physical key code (which key on the keyboard). Chrome:dom_code(physical) +dom_key(logical). We start with physical only — logical keys added when IME support lands. -
state: Pressed or Released. Chrome: encoded in the event type (kKeyDownvskKeyUp). -
modifiers: Includesis_auto_repeatflag for held keys. Chrome:modifiers_ & kIsAutoRepeat. -
text: The character(s) produced by this key press, if any. Chrome:WebKeyboardEvent::text[4](UTF-16). We useOption<String>(UTF-8) — Rust native. -
timestamp: When this event was received from the OS. Chrome:WebInputEvent::time_stamp_.
Fields§
§key: KeyCodePhysical key code — which key was pressed.
state: ButtonStateWhether the key was pressed or released.
modifiers: ModifiersModifier keys and auto-repeat flag.
text: Option<String>Text input produced by this key press (if any). None for modifier keys, function keys, etc.
timestamp: InstantWhen this event was received from the OS.
Trait Implementations§
Source§impl Clone for KeyboardEvent
impl Clone for KeyboardEvent
Source§fn clone(&self) -> KeyboardEvent
fn clone(&self) -> KeyboardEvent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for KeyboardEvent
impl RefUnwindSafe for KeyboardEvent
impl Send for KeyboardEvent
impl Sync for KeyboardEvent
impl Unpin for KeyboardEvent
impl UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more