Struct input_pipeline::keyboard_binding::KeyboardEvent
source · 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
source§fn eq(&self, other: &KeyboardEvent) -> bool
fn eq(&self, other: &KeyboardEvent) -> bool
self
and other
values to be equal, and is used
by ==
.