pub struct KeyCombination {
pub codes: OneToThree<KeyCode>,
pub modifiers: KeyModifiers,
}Expand description
A Key combination wraps from one to three standard keys with optional modifiers (ctrl, alt, shift).
Fields§
§codes: OneToThree<KeyCode>§modifiers: KeyModifiersImplementations§
Source§impl KeyCombination
impl KeyCombination
Sourcepub fn new<C>(codes: C, modifiers: KeyModifiers) -> KeyCombination
pub fn new<C>(codes: C, modifiers: KeyModifiers) -> KeyCombination
Create a new KeyCombination from one to three keycodes and a set of modifiers
Sourcepub const fn one_key(code: KeyCode, modifiers: KeyModifiers) -> KeyCombination
pub const fn one_key(code: KeyCode, modifiers: KeyModifiers) -> KeyCombination
Create a new KeyCombination from one keycode and a set of modifiers
Sourcepub const fn is_ansi_compatible(self) -> bool
pub const fn is_ansi_compatible(self) -> bool
Ansi terminals don’t manage key press/release/repeat, so they don’t allow to determine whether 2 keys are pressed at the same time. This means a combination involving several key codes can’t be distiguished from a sequences of combinations involving a single key code. For this reason, only combinations involving a single key code are considered “ansi compatible”
Sourcepub fn normalized(self) -> KeyCombination
pub fn normalized(self) -> KeyCombination
Return a normailzed version of the combination.
Fix the case of the code to uppercase if the shift modifier is present. Add the SHIFT modifier if one code is uppercase.
This allows direct comparisons with the fields of crossterm::event::KeyEvent
whose code is uppercase when the shift modifier is present. And supports the
case where the modifier isn’t mentionned but the key is uppercase.
Trait Implementations§
Source§impl Clone for KeyCombination
impl Clone for KeyCombination
Source§fn clone(&self) -> KeyCombination
fn clone(&self) -> KeyCombination
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for KeyCombination
impl Debug for KeyCombination
Source§impl<'de> Deserialize<'de> for KeyCombination
Available on crate feature serde only.
impl<'de> Deserialize<'de> for KeyCombination
serde only.Source§fn deserialize<D>(
deserializer: D,
) -> Result<KeyCombination, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<KeyCombination, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl Display for KeyCombination
impl Display for KeyCombination
Source§impl From<KeyCode> for KeyCombination
impl From<KeyCode> for KeyCombination
Source§fn from(key_code: KeyCode) -> KeyCombination
fn from(key_code: KeyCode) -> KeyCombination
Source§impl From<KeyCombination> for Trigger
impl From<KeyCombination> for Trigger
Source§fn from(key: KeyCombination) -> Self
fn from(key: KeyCombination) -> Self
Source§impl From<KeyEvent> for KeyCombination
impl From<KeyEvent> for KeyCombination
Source§fn from(key_event: KeyEvent) -> KeyCombination
fn from(key_event: KeyEvent) -> KeyCombination
Source§impl FromStr for KeyCombination
impl FromStr for KeyCombination
Source§type Err = ParseKeyError
type Err = ParseKeyError
Source§fn from_str(s: &str) -> Result<KeyCombination, ParseKeyError>
fn from_str(s: &str) -> Result<KeyCombination, ParseKeyError>
s to return a value of this type. Read moreSource§impl Hash for KeyCombination
impl Hash for KeyCombination
Source§impl Into<KeyEvent> for KeyCombination
impl Into<KeyEvent> for KeyCombination
Source§impl Ord for KeyCombination
impl Ord for KeyCombination
Source§fn cmp(&self, other: &KeyCombination) -> Ordering
fn cmp(&self, other: &KeyCombination) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for KeyCombination
impl PartialEq for KeyCombination
Source§impl PartialOrd for KeyCombination
impl PartialOrd for KeyCombination
Source§impl Serialize for KeyCombination
Available on crate feature serde only.
impl Serialize for KeyCombination
serde only.Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Source§impl TryFrom<&[KeyEvent]> for KeyCombination
impl TryFrom<&[KeyEvent]> for KeyCombination
Source§fn try_from(
key_events: &[KeyEvent],
) -> Result<KeyCombination, <KeyCombination as TryFrom<&[KeyEvent]>>::Error>
fn try_from( key_events: &[KeyEvent], ) -> Result<KeyCombination, <KeyCombination as TryFrom<&[KeyEvent]>>::Error>
Try to create a KeyCombination from a slice of key events,
will fail if and only if the slice is empty.
impl Copy for KeyCombination
impl Eq for KeyCombination
impl StructuralPartialEq for KeyCombination
Auto Trait Implementations§
impl Freeze for KeyCombination
impl RefUnwindSafe for KeyCombination
impl Send for KeyCombination
impl Sync for KeyCombination
impl Unpin for KeyCombination
impl UnsafeUnpin for KeyCombination
impl UnwindSafe for KeyCombination
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,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<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.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>
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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more