pub struct KeyEvent {
pub key: Key,
pub modifiers: KeyModifiers,
}Expand description
A key-down event: the logical Key that was pressed plus the
KeyModifiers held at that moment.
This is the direct analog of magiblot’s TKey canonical form (which
already decomposed a keystroke into base code + modifier mask). Construct
with KeyEvent::from for the no-modifier case, or KeyEvent::new with
explicit modifiers:
use tvision_rs::event::{Key, KeyEvent, KeyModifiers};
// Enter with no modifiers:
let enter = KeyEvent::from(Key::Enter);
// Ctrl+S:
let ctrl_s = KeyEvent::new(Key::Char('s'), KeyModifiers { ctrl: true, ..Default::default() });Match a KeyEvent in View::handle_event by
destructuring Event::KeyDown(ke) and checking ke.key and ke.modifiers.
§Turbo Vision heritage
Ports the KeyDownEvent sub-record (system.h) and the TKey canonical
form (tkeys.h/tkey.cpp). TKey already decomposed each keystroke into
base code + modifier mask; tvision-rs keeps that decomposition as the Key
enum + KeyModifiers (deviations D4 and D5).
Fields§
§key: KeyThe logical key that was pressed, without modifier encoding.
modifiers: KeyModifiersThe modifiers (shift, ctrl, alt) held while the key was pressed.
Implementations§
Trait Implementations§
impl Copy for KeyEvent
impl Eq for KeyEvent
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 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
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.