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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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> Encode<Ambiguous1> for T

source§

unsafe fn encode( self, _encoder: &mut Encoder<'_>, _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> Encode<Ambiguous2> for T

source§

unsafe fn encode( self, _encoder: &mut Encoder<'_>, _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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

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

§

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

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,

§

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>,

§

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>,

§

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

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
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