Enum KeyEventType
#[repr(u32)]pub enum KeyEventType {
Pressed = 1,
Released = 2,
Sync = 3,
Cancel = 4,
}
Expand description
Type of the keyboard key input event.
We do not expect new values to be added into this enum.
Variants§
Pressed = 1
Key is actuated.
Receiving this event type means that a key has been actuated at the timestamp when the event is received, and while the event recipient is focused.
For example, if the key is a keyboard key, then it was just pressed.
Released = 2
Key is no longer actuated.
Receiving this event type means that a key has been de-actuated at the timestamp when the event is received, and while the event recipient is focused.
For example, if the key is a keyboard key, then it was just released.
Sync = 3
Key was actuated while the client wasn’t able to receive it, and is still actuated now that the client is able to receive key events.
This may happen in a few ways:
- A new device was connected while its key was actuated.
- The key was actuated while the event recipient did not have focus.
Therefore, this is not a “regular” key actuation. It reports now that the key has been actuated in the unknown past. Some event recipients may therefore decide that this is not an actionable key event, while some others may decide that it is.
For example, recipients that trigger some user action may
decide to ignore SYNC
events, to avoid spurious actions. In
contrast, recipients that keep track of the keyboard
state may want to consider a SYNC
event as a signal
to update the key’s state to actuated.
Cancel = 4
Key may have been actuated, but its actuation has become invalid due to an event other than a key de-actuation.
This may happen in a few ways:
- A device was disconnected while its key was actuated.
- The event recipient just lost focus.
Therefore, this is not a “regular” key de-actuation. It reports the key is no longer validly actuated due to an event other than a key release. Some event recipients may therefore decide that this is not an actionable key event, while some others may decide that it is.
For example, recipients which trigger some user action may
decide to ignore CANCEL
events, to avoid spurious actions. In
contrast, recipients that keep track of the keyboard
state may want to consider a CANCEL
event as a signal to update
the key’s state to being de-actuated.
Implementations§
§impl KeyEventType
impl KeyEventType
pub fn from_primitive(prim: u32) -> Option<KeyEventType>
pub const fn into_primitive(self) -> u32
pub fn is_unknown(&self) -> bool
is_unknown
Trait Implementations§
§impl Clone for KeyEventType
impl Clone for KeyEventType
§fn clone(&self) -> KeyEventType
fn clone(&self) -> KeyEventType
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for KeyEventType
impl Debug for KeyEventType
§impl<D> Decode<KeyEventType, D> for KeyEventTypewhere
D: ResourceDialect,
impl<D> Decode<KeyEventType, D> for KeyEventTypewhere
D: ResourceDialect,
§fn new_empty() -> KeyEventType
fn new_empty() -> KeyEventType
Self
. The specific value does not matter,
since it will be overwritten by decode
.§impl<D> Encode<KeyEventType, D> for KeyEventTypewhere
D: ResourceDialect,
impl<D> Encode<KeyEventType, D> for KeyEventTypewhere
D: ResourceDialect,
§impl Hash for KeyEventType
impl Hash for KeyEventType
§impl Ord for KeyEventType
impl Ord for KeyEventType
§impl PartialEq for KeyEventType
impl PartialEq for KeyEventType
§impl PartialOrd for KeyEventType
impl PartialOrd for KeyEventType
§impl TypeMarker for KeyEventType
impl TypeMarker for KeyEventType
§type Owned = KeyEventType
type Owned = KeyEventType
§fn inline_align(_context: Context) -> usize
fn inline_align(_context: Context) -> usize
§fn inline_size(_context: Context) -> usize
fn inline_size(_context: Context) -> usize
inline_align
.§fn encode_is_copy() -> bool
fn encode_is_copy() -> bool
Self::Owned
matches the FIDL wire
format and encoding requires no validation. When true, we can optimize
encoding arrays and vectors of Self::Owned
to a single memcpy. Read more§fn decode_is_copy() -> bool
fn decode_is_copy() -> bool
Self::Owned
matches the FIDL wire
format and decoding requires no validation. When true, we can optimize
decoding arrays and vectors of Self::Owned
to a single memcpy.§impl ValueTypeMarker for KeyEventType
impl ValueTypeMarker for KeyEventType
§type Borrowed<'a> = KeyEventType
type Borrowed<'a> = KeyEventType
Encode<Self>
type cheaply obtainable from &Self::Owned
. There are three cases: Read more§fn borrow(
value: &<KeyEventType as TypeMarker>::Owned,
) -> <KeyEventType as ValueTypeMarker>::Borrowed<'_>
fn borrow( value: &<KeyEventType as TypeMarker>::Owned, ) -> <KeyEventType as ValueTypeMarker>::Borrowed<'_>
&Self::Owned
to Self::Borrowed
.