#[repr(C)]pub struct WebEventKey {
pub key: js_uint32,
pub state: KeyState,
pub location: WebKeyLocation,
pub mods: KeyMods,
pub timestamp: JsInstant,
}event and web only.Expand description
๐ซ ๐ A web API keyboard event.
๐ sys/os/browser/web
๐ฆ size_of::<WebEventKey>() == 16 bytes / 128 bits
โ๏ธOption<T>
Represents a JavaScript KeyboardEvent in a compact callback-friendly form.
key is the Unicode scalar value of KeyboardEvent.key when it contains
exactly one Unicode scalar, or 0 for non-text keys such as Enter.
Fieldsยง
ยงkey: js_uint32Unicode scalar from KeyboardEvent.key, or 0 for non-text keys.
state: KeyStateThe key transition state.
location: WebKeyLocationWhich part of the keyboard produced the event.
mods: KeyModsActive keyboard modifiers.
timestamp: JsInstantThe JavaScript event timestamp.
Implementationsยง
Sourceยงimpl WebEventKey
impl WebEventKey
Sourcepub const fn new(
key: js_uint32,
state: KeyState,
location: WebKeyLocation,
mods: KeyMods,
timestamp: JsInstant,
) -> Self
pub const fn new( key: js_uint32, state: KeyState, location: WebKeyLocation, mods: KeyMods, timestamp: JsInstant, ) -> Self
Returns a new keyboard event.
Sourcepub const fn has_key_scalar(self) -> bool
pub const fn has_key_scalar(self) -> bool
Returns whether this event carries a text scalar.
Sourcepub const fn to_event_key(self) -> EventKey
pub const fn to_event_key(self) -> EventKey
Converts WebEventKey to a normalized EventKey.
Returns None if the web event kind is not a keyboard event.
Sourcepub const fn to_kind_timed(self) -> EventKindTimed
pub const fn to_kind_timed(self) -> EventKindTimed
Converts WebEventKey to EventKindTimed.
Returns None if the web event kind is not a keyboard event.
Sourcepub const fn from_event_key(from: EventKey) -> WebEventKey
pub const fn from_event_key(from: EventKey) -> WebEventKey
Converts a normalized EventKey back to WebEventKey.
This is necessarily partial because WebEventKey stores only a
scalar key, not the browser KeyboardEvent.key and
KeyboardEvent.code strings.
Sourcepub const fn from_event_key_timed(
from: Timed<EventKey, Option<EventTimestamp>>,
) -> WebEventKey
pub const fn from_event_key_timed( from: Timed<EventKey, Option<EventTimestamp>>, ) -> WebEventKey
Converts a timed normalized EventKey back to WebEventKey.
Trait Implementationsยง
Sourceยงimpl Clone for WebEventKey
impl Clone for WebEventKey
Sourceยงfn clone(&self) -> WebEventKey
fn clone(&self) -> WebEventKey
1.0.0 (const: unstable) ยท Sourceยงfn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for WebEventKey
Sourceยงimpl Debug for WebEventKey
impl Debug for WebEventKey
Sourceยงimpl From<Timed<EventKey, Option<EventTimestamp>>> for WebEventKey
impl From<Timed<EventKey, Option<EventTimestamp>>> for WebEventKey
Sourceยงimpl From<WebEventKey> for EventKindTimed
impl From<WebEventKey> for EventKindTimed
Sourceยงfn from(from: WebEventKey) -> Self
fn from(from: WebEventKey) -> Self
Sourceยงimpl PartialEq for WebEventKey
impl PartialEq for WebEventKey
Sourceยงfn eq(&self, other: &WebEventKey) -> bool
fn eq(&self, other: &WebEventKey) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for WebEventKey
Auto Trait Implementationsยง
impl Freeze for WebEventKey
impl RefUnwindSafe for WebEventKey
impl Send for WebEventKey
impl Sync for WebEventKey
impl Unpin for WebEventKey
impl UnsafeUnpin for WebEventKey
impl UnwindSafe for WebEventKey
Blanket Implementationsยง
Sourceยงimpl<T> AnyExt for T
impl<T> AnyExt for T
Sourceยงfn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
TypeId of Self using a custom hasher.Sourceยงfn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
Sourceยงfn as_any_box(self: Box<Self>) -> Box<dyn Any>where
Self: Sized,
fn as_any_box(self: Box<Self>) -> Box<dyn Any>where
Self: Sized,
alloc only.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
Sourceยงimpl<T> ByteSized for T
impl<T> ByteSized for T
Sourceยงconst BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
Sourceยงfn byte_align(&self) -> usize
fn byte_align(&self) -> usize
Sourceยงfn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
Sourceยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Sourceยงimpl<T> MemExt for Twhere
T: ?Sized,
impl<T> MemExt for Twhere
T: ?Sized,
Sourceยงconst NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Sourceยงfn mem_align_of<T>() -> usize
fn mem_align_of<T>() -> usize
Sourceยงfn mem_align_of_val(&self) -> usize
fn mem_align_of_val(&self) -> usize
Sourceยงfn mem_size_of<T>() -> usize
fn mem_size_of<T>() -> usize
Sourceยงfn mem_size_of_val(&self) -> usize
fn mem_size_of_val(&self) -> usize
Sourceยงfn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true if dropping values of this type matters. Read moreSourceยงfn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self without running its destructor. Read moreSourceยงfn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Sourceยงunsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
unsafe_layout only.T represented by the all-zero byte-pattern. Read moreSourceยงunsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe_layout only.T represented by the all-zero byte-pattern. Read moreSourceยงfn mem_as_bytes(&self) -> &[u8] โ
fn mem_as_bytes(&self) -> &[u8] โ
unsafe_slice only.