input_pipeline::keyboard_binding

Struct 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:

  1. KeyEventType::Pressed: the key has transitioned to being pressed.
  2. 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

Source

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.

Source

pub fn into_with_autorepeat_settings( self, autorepeat_settings: Option<Settings>, ) -> Self

Converts KeyboardEvent into the same one, but with the specified settings.

Source

pub fn get_autorepeat_settings(&self) -> Settings

Source

pub fn get_key(&self) -> Key

Source

pub fn into_with_key(self, key: Key) -> Self

Converts KeyboardEvent into the same one, but with specified key.

Source

pub fn get_event_type(&self) -> KeyEventType

Source

pub fn into_with_event_type(self, event_type: KeyEventType) -> Self

Converts KeyboardEvent into the same one, but with specified event type.

Source

pub fn into_with_folded_event(self) -> Self

Folds the key event type into an active event (Pressed, Released).

Source

pub fn get_event_type_folded(&self) -> KeyEventType

Gets KeyEventType, folding SYNC into PRESSED and CANCEL into RELEASED.

Source

pub fn into_with_modifiers(self, modifiers: Option<Modifiers>) -> Self

Converts KeyboardEvent into the same one, but with specified modifiers.

Source

pub fn get_modifiers(&self) -> Option<Modifiers>

Returns the currently applicable modifiers.

Source

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

Source

pub fn into_with_lock_state(self, lock_state: Option<LockState>) -> Self

Converts KeyboardEvent into the same one, but with the specified lock state.

Source

pub fn get_lock_state(&self) -> Option<LockState>

Returns the currently applicable lock state.

Source

pub fn into_with_keymap(self, keymap: Option<String>) -> Self

Converts KeyboardEvent into the same one, but with the specified keymap applied.

Source

pub fn get_keymap(&self) -> Option<String>

Returns the currently applied keymap.

Source

pub fn into_with_key_meaning(self, key_meaning: Option<KeyMeaning>) -> Self

Converts KeyboardEvent into the same one, but with the key meaning applied.

Source

pub fn get_key_meaning(&self) -> Option<KeyMeaning>

Returns the currently valid key meaning.

Source

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.

Source

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

Source

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

Source§

fn clone(&self) -> KeyboardEvent

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for KeyboardEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for KeyboardEvent

Source§

fn eq(&self, other: &KeyboardEvent) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for KeyboardEvent

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsRcAny for T
where T: Any,

Source§

fn as_rc_any(self: Rc<T>) -> Rc<dyn Any>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T, D> Encode<Ambiguous1, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<T, D> Encode<Ambiguous2, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoAny for T
where T: 'static + Send + Sync,

Source§

fn into_any(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Cast the given object into a dyn std::any::Any.
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

Source§

impl<St> WithTag for St

Source§

fn tagged<T>(self, tag: T) -> Tagged<T, St>

Produce a new stream from this one which yields item tupled with a constant tag