pub struct KeyInput {
pub key: KeyCode,
pub modifiers: Modifiers,
}Expand description
A representation of a keyboard input.
§Examples
§Single key
use edtui::events::KeyInput;
let input = KeyInput::new('s');§Key with one modifier
use edtui::events::KeyInput;
use crossterm::event::KeyCode;
let input = KeyInput::ctrl(KeyCode::Esc);§Key with multiple modifiers
use edtui::events::KeyInput;
use crossterm::event::KeyModifiers;
let input = KeyInput::with_modifiers('k', KeyModifiers::CONTROL | KeyModifiers::SHIFT);Fields§
§key: KeyCode§modifiers: ModifiersImplementations§
Source§impl KeyInput
impl KeyInput
Sourcepub fn with_modifiers<K: Into<KeyCode>, M: Into<Modifiers>>(
key: K,
modifiers: M,
) -> Self
pub fn with_modifiers<K: Into<KeyCode>, M: Into<Modifiers>>( key: K, modifiers: M, ) -> Self
Create a key input with a set of modifiers. Supports shift, ctrl and alt.
Sourcepub fn normalize_altgr(self) -> Self
pub fn normalize_altgr(self) -> Self
Normalize AltGr key events for international keyboard support.
Strips Ctrl+Alt modifiers from non-alphabetic characters, allowing
symbols like [, ], {, }, \, @ to be typed on keyboards
where these require AltGr (e.g., German, Swiss German).
Trait Implementations§
impl Copy for KeyInput
impl Eq for KeyInput
impl StructuralPartialEq for KeyInput
Auto Trait Implementations§
impl Freeze for KeyInput
impl RefUnwindSafe for KeyInput
impl Send for KeyInput
impl Sync for KeyInput
impl Unpin for KeyInput
impl UnsafeUnpin for KeyInput
impl UnwindSafe for KeyInput
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
Mutably borrows from an owned value. Read more
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more