#[non_exhaustive]pub struct KeyPress {
pub logical: LogicalKey,
pub physical: PhysicalKey,
pub modifiers: KeyModifiers,
pub repeat: bool,
}Expand description
One keyboard key-down, as delivered on UiEvent::key_press.
Hosts feed the constituent parts through
[crate::runtime::RunnerCore::key_down]; the runtime packages them
into this struct on the events it emits.
Two of the three W3C key facets live here: logical
(the key’s meaning) and physical (its
layout-independent position). The third — committed text — is a
separate UiEventKind::TextInput event (UiEvent::text), so this
struct never carries produced text.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.logical: LogicalKeyThe logical key — meaning under the active layout + modifiers. Use for activation, navigation, and legend-following accelerators.
physical: PhysicalKeyThe physical key — layout-independent board position. Use for
rebindable controls, games, global hotkeys, and disambiguating
duplicate keys (numpad vs main row). PhysicalKey::Unidentified
when the host can’t report a position.
modifiers: KeyModifiersModifier mask at the moment of the press.
repeat: boolTrue when this press is an OS auto-repeat of a held key rather than a fresh key-down.
Implementations§
Source§impl KeyPress
impl KeyPress
Sourcepub fn new(
logical: LogicalKey,
physical: PhysicalKey,
modifiers: KeyModifiers,
repeat: bool,
) -> Self
pub fn new( logical: LogicalKey, physical: PhysicalKey, modifiers: KeyModifiers, repeat: bool, ) -> Self
Construct a key press from its facets. Hosts call this to feed
[crate::runtime::RunnerCore::key_down]. KeyPress is
#[non_exhaustive], so this constructor is the supported way to
build one outside the core crate.
Trait Implementations§
impl Eq for KeyPress
impl StructuralPartialEq for KeyPress
Auto Trait Implementations§
impl Freeze for KeyPress
impl RefUnwindSafe for KeyPress
impl Send for KeyPress
impl Sync for KeyPress
impl Unpin for KeyPress
impl UnsafeUnpin for KeyPress
impl UnwindSafe for KeyPress
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.