#[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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.key: SharedStringThe 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: SharedStringThe 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: ModifiersThe modifiers held after this transition. Releasing one Shift keeps
shift set while the other Shift is still held.
repeat: boolAn auto-repeat of a key held down (the press itself is not one).
default_prevented: boolWhether 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.