pub struct KeyEvent {
pub key: Key,
pub ctrl: bool,
pub alt: bool,
pub shift: bool,
}Expand description
A Key plus the modifier keys held with it. Named fields (not a
bitflag) so a test/keymap-string reader can construct one by hand
without needing to know a bit layout.
Fields§
§key: KeyThe key itself.
ctrl: boolCtrl held.
alt: boolAlt held.
shift: boolShift held. Deliberately still tracked even for Key::Char (whose
case already reflects shift) because some non-alpha chars (arrows,
tab) have a distinct shifted meaning (BackTab for Shift+Tab is
modeled as its own Key variant by the translator, not via this
flag — this flag exists for completeness/testability of a caller
that wants to distinguish, e.g., a raw Shift+Left selection chord in
a future extension).
Implementations§
Source§impl KeyEvent
impl KeyEvent
Sourcepub const fn plain(key: Key) -> KeyEvent
pub const fn plain(key: Key) -> KeyEvent
A plain, unmodified key — the common case in tests/default bindings.
Sourcepub const fn ch(c: char) -> KeyEvent
pub const fn ch(c: char) -> KeyEvent
A plain printable character — shorthand for
KeyEvent::plain(Key::Char(c)), the single most common test/keymap
construction.
Sourcepub fn parse(spec: &str) -> Option<KeyEvent>
pub fn parse(spec: &str) -> Option<KeyEvent>
Parse the small keymap-string syntax capabilities.tui.keymap.<action> = "<key>" (§3.1) understands: an optional ctrl+/alt+/shift+
prefix (any order, +-joined) followed by either a single
character or a named key (enter, esc/escape, backspace,
delete/del, tab, up, down, left, right, home, end,
pageup/pgup, pagedown/pgdn, f1..f12). Case-insensitive
except the bare single-character form, which is taken literally (so
"R" and "r" are distinct plain characters, while "Ctrl+R" and
"ctrl+r" are the same chord). Returns None for anything it
doesn’t recognize — a caller (crate::tui::Keymap::with_overrides)
treats an unparseable override as “keep the default”, never a panic
or a silently-wrong binding.
Trait Implementations§
impl Copy for KeyEvent
impl Eq for KeyEvent
impl StructuralPartialEq for KeyEvent
Auto Trait Implementations§
impl Freeze for KeyEvent
impl RefUnwindSafe for KeyEvent
impl Send for KeyEvent
impl Sync for KeyEvent
impl Unpin for KeyEvent
impl UnsafeUnpin for KeyEvent
impl UnwindSafe for KeyEvent
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§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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.