Skip to main content

KeyEvent

Struct KeyEvent 

Source
#[non_exhaustive]
pub struct KeyEvent { pub key: SharedString, pub code: SharedString, pub modifiers: Modifiers, pub repeat: bool, pub default_prevented: bool, }
Expand description

A key that went down or came up on the focused view (on_key_down / on_key_up), as GPUI’s KeyDownEvent.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§key: SharedString

The logical key the source reports: the DOM’s spelling for named keys ("Enter", "Escape", "ArrowLeft") and the character a printable key reports in its actual case, on the layout in use. Not normalized to another layout. "Unidentified" when the source names none.

§code: SharedString

The key’s physical identity as the DOM’s KeyboardEvent.code spells it ("KeyA", "ArrowLeft", "NumpadEnter", "ShiftLeft"), mapped by the backend from the native identifier it really has: a Windows scan code, AppKit’s NSEvent.keyCode, or a GTK hardware keycode; browsers provide their DOM code directly. "" when the source has no physical identity (GPUI’s logical events, synthetic input): the empty string is the DOM’s unknown code, and no backend infers a code from the printable or logical key.

§modifiers: Modifiers

The modifiers held after this transition. Releasing one Shift keeps shift set while the other Shift is still held.

§repeat: bool

An auto-repeat of a key held down (the press itself is not one).

§default_prevented: bool

Whether the mounted KeyCapture rule of the focused view or an enabled ancestor decided this transition before it ran: the platform runs no native default and types no text. It is the decision for this one transition, observable state as the DOM’s defaultPrevented is, not a veto a listener can cast: the UI thread does not wait for engine-thread JS or Rust callbacks, which are told after the fact.

Trait Implementations§

Source§

impl Clone for KeyEvent

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for KeyEvent

Source§

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

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

impl Default for KeyEvent

Source§

fn default() -> Self

A key the source has not identified.

Source§

impl Eq for KeyEvent

Source§

impl PartialEq for KeyEvent

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for KeyEvent

Auto Trait Implementations§

§

impl Forget for KeyEvent

§

impl Freeze for KeyEvent
where &'static str: Freeze, *const ArcInner<str> is !null: Freeze, PhantomData<ArcInner<str>>: Freeze,

§

impl Move for KeyEvent

§

impl RefUnwindSafe for KeyEvent

§

impl Send for KeyEvent
where &'static str: Send, Arc<str>: Send,

§

impl Sync for KeyEvent
where Arc<str>: Sync,

§

impl Unpin for KeyEvent
where &'static str: Unpin, Arc<str>: Unpin,

§

impl UnsafeUnpin for KeyEvent
where &'static str: UnsafeUnpin, *const ArcInner<str> is !null: UnsafeUnpin, PhantomData<ArcInner<str>>: UnsafeUnpin,

§

impl UnwindSafe for KeyEvent
where &'static str: UnwindSafe, Arc<str>: UnwindSafe,

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> 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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.