pub enum Key {
}Expand description
A logical, modifier-free key — the base of a KeyEvent.
Keyboard keys and key-down events.
A keystroke is modeled the idiomatic, crossterm-shaped way: a closed Key
enum of physical keys plus a separate KeyModifiers channel. There are
deliberately no modifier-combined variants: Ctrl+C is Key::Char('c')
plus ctrl, Shift+Tab is Key::Tab plus shift, and Alt+F3 is
Key::F(3) plus alt. A KeyEvent pairs a key with the modifiers active
when it was pressed.
There is no “no key” value: the absence of a keystroke is the absence of a key event.
Only the 16 base keys appear here; modifier combinations are expressed by
pairing a Key with a KeyModifiers in a KeyEvent:
Ctrl+C→Key::Char('c')+modifiers.ctrl = trueShift+Tab→Key::Tab+modifiers.shift = trueAlt+F3→Key::F(3)+modifiers.alt = true
This replaces the ~150 kb* combined key+modifier constants from tkeys.h;
each constant was a specific bitwise combination of a scan code and a
modifier mask. Here the two dimensions are orthogonal and independently
matchable.
There is no BackTab variant. Shift+Tab is Key::Tab with shift set.
Raw hardware scan codes are not preserved (they are DOS-era platform data
with no cross-platform meaning).
§Turbo Vision heritage
Ports the kb* key-code family, the TKey class (tkeys.h / tkey.cpp),
and KeyDownEvent (system.h). TKey’s canonical form already decomposes
each keystroke into a base code plus a modifier mask (Ctrl+A is 'A' with the
ctrl-shift mask; Shift+Tab is the Tab code with the shift mask); tvision-rs keeps
that decomposition as the Key enum and a separate KeyModifiers
(deviations D4 and D5).
Ports the kb* key-code family (tkeys.h) and the TKey canonical form
(tkeys.h / tkey.cpp); the 1992 guide’s charCode: Char (low byte) maps
to Key::Char(char) carrying the full Unicode character. Deviations D4 and D5.
Variants§
Char(char)
A printable character: letters, digits, symbols, and space.
Holds the base character case-as-typed; case modification and
Ctrl/Alt semantics live in the accompanying KeyModifiers.
The 1992 guide’s charCode: Char (low byte of keyCode: Word) maps
here, extended to full Unicode.
F(u8)
A function key, F(1)..=F(12).
Enter
The Enter/Return key.
Esc
The Escape key.
Backspace
The Backspace key.
Tab
The Tab key. Note there is no BackTab variant: Shift+Tab is Tab + the
shift modifier.
Up
The Up arrow key.
Down
The Down arrow key.
Left
The Left arrow key.
Right
The Right arrow key.
Home
The Home key.
End
The End key.
PageUp
The Page Up key.
PageDown
The Page Down key.
Insert
The Insert key.
Delete
The Delete key.
Trait Implementations§
impl Copy for Key
impl Eq for Key
Source§impl From<Key> for KeyEvent
The common no-modifier case: KeyEvent::from(Key::Enter) yields an event
with all modifiers cleared.
impl From<Key> for KeyEvent
The common no-modifier case: KeyEvent::from(Key::Enter) yields an event
with all modifiers cleared.
impl StructuralPartialEq for Key
Auto Trait Implementations§
impl Freeze for Key
impl RefUnwindSafe for Key
impl Send for Key
impl Sync for Key
impl Unpin for Key
impl UnsafeUnpin for Key
impl UnwindSafe for Key
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.