pub struct KeyboardEvent { /* private fields */ }
Expand description
A KeyboardEvent
represents an input event from a keyboard device.
The keyboard event contains information about a key event. A key event represents a change in the key state. Clients can expect the following sequence of events for a given key:
KeyEventType::Pressed
: the key has transitioned to being pressed.KeyEventType::Released
: the key has transitioned to being released.
No duplicate KeyEventType::Pressed
events will be sent for keys, even if the
key is present in a subsequent InputReport
. Clients can assume that
a key is pressed for all received input events until the key is present in
the KeyEventType::Released
entry of [keys
].
Use new
to create. Use get_*
methods to read fields. Use into_with_*
methods to add optional information.
Implementations§
Source§impl KeyboardEvent
impl KeyboardEvent
Sourcepub fn new(key: Key, event_type: KeyEventType) -> Self
pub fn new(key: Key, event_type: KeyEventType) -> Self
Creates a new KeyboardEvent, with required fields filled out. Use the
into_with_*
methods to add optional information.
Sourcepub fn into_with_autorepeat_settings(
self,
autorepeat_settings: Option<Settings>,
) -> Self
pub fn into_with_autorepeat_settings( self, autorepeat_settings: Option<Settings>, ) -> Self
Converts KeyboardEvent into the same one, but with the specified settings.
pub fn get_autorepeat_settings(&self) -> Settings
pub fn get_key(&self) -> Key
Sourcepub fn into_with_key(self, key: Key) -> Self
pub fn into_with_key(self, key: Key) -> Self
Converts KeyboardEvent into the same one, but with specified key.
pub fn get_event_type(&self) -> KeyEventType
Sourcepub fn into_with_event_type(self, event_type: KeyEventType) -> Self
pub fn into_with_event_type(self, event_type: KeyEventType) -> Self
Converts KeyboardEvent into the same one, but with specified event type.
Sourcepub fn into_with_folded_event(self) -> Self
pub fn into_with_folded_event(self) -> Self
Folds the key event type into an active event (Pressed, Released).
Sourcepub fn get_event_type_folded(&self) -> KeyEventType
pub fn get_event_type_folded(&self) -> KeyEventType
Gets KeyEventType, folding SYNC
into PRESSED
and CANCEL
into RELEASED
.
Sourcepub fn into_with_modifiers(self, modifiers: Option<Modifiers>) -> Self
pub fn into_with_modifiers(self, modifiers: Option<Modifiers>) -> Self
Converts KeyboardEvent into the same one, but with specified modifiers.
Sourcepub fn get_modifiers(&self) -> Option<Modifiers>
pub fn get_modifiers(&self) -> Option<Modifiers>
Returns the currently applicable modifiers.
Sourcepub fn get_unsided_modifiers(&self) -> Modifiers
pub fn get_unsided_modifiers(&self) -> Modifiers
Returns the currently applicable modifiers, with the sided modifiers removed.
For example, if LEFT_SHIFT is pressed, returns SHIFT, rather than SHIFT | LEFT_SHIFT
Sourcepub fn into_with_lock_state(self, lock_state: Option<LockState>) -> Self
pub fn into_with_lock_state(self, lock_state: Option<LockState>) -> Self
Converts KeyboardEvent into the same one, but with the specified lock state.
Sourcepub fn get_lock_state(&self) -> Option<LockState>
pub fn get_lock_state(&self) -> Option<LockState>
Returns the currently applicable lock state.
Sourcepub fn into_with_keymap(self, keymap: Option<String>) -> Self
pub fn into_with_keymap(self, keymap: Option<String>) -> Self
Converts KeyboardEvent into the same one, but with the specified keymap applied.
Sourcepub fn get_keymap(&self) -> Option<String>
pub fn get_keymap(&self) -> Option<String>
Returns the currently applied keymap.
Sourcepub fn into_with_key_meaning(self, key_meaning: Option<KeyMeaning>) -> Self
pub fn into_with_key_meaning(self, key_meaning: Option<KeyMeaning>) -> Self
Converts KeyboardEvent into the same one, but with the key meaning applied.
Sourcepub fn get_key_meaning(&self) -> Option<KeyMeaning>
pub fn get_key_meaning(&self) -> Option<KeyMeaning>
Returns the currently valid key meaning.
Sourcepub fn get_repeat_sequence(&self) -> u32
pub fn get_repeat_sequence(&self) -> u32
Returns the repeat sequence number. If a nonzero number N is returned, that means this KeyboardEvent is the N-th generated autorepeat event. A zero means this is an event that came from the keyboard driver.
Sourcepub fn into_with_repeat_sequence(self, repeat_sequence: u32) -> Self
pub fn into_with_repeat_sequence(self, repeat_sequence: u32) -> Self
Converts KeyboardEvent into the same one, but with the repeat sequence changed.
Source§impl KeyboardEvent
impl KeyboardEvent
Sourcepub fn same_key(this: &KeyboardEvent, that: &KeyboardEvent) -> bool
pub fn same_key(this: &KeyboardEvent, that: &KeyboardEvent) -> bool
Returns true if the two keyboard events are about the same key.
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 moreSource§impl Debug for KeyboardEvent
impl Debug for KeyboardEvent
Source§impl PartialEq for KeyboardEvent
impl PartialEq 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)