Struct crokey::KeyCombination
source · 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: KeyModifiers
Implementations§
source§impl KeyCombination
impl KeyCombination
sourcepub fn new<C: Into<OneToThree<KeyCode>>>(
codes: C,
modifiers: KeyModifiers
) -> Self
pub fn new<C: Into<OneToThree<KeyCode>>>( codes: C, modifiers: KeyModifiers ) -> Self
Create a new KeyCombination from one to three keycodes and a set of modifiers
sourcepub const fn one_key(code: KeyCode, modifiers: KeyModifiers) -> Self
pub const fn one_key(code: KeyCode, modifiers: KeyModifiers) -> Self
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) -> Self
pub fn normalized(self) -> Self
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
impl<'de> Deserialize<'de> for KeyCombination
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::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§impl From<KeyEvent> for KeyCombination
impl From<KeyEvent> for KeyCombination
source§impl FromStr for KeyCombination
impl FromStr for KeyCombination
§type Err = ParseKeyError
type Err = ParseKeyError
source§impl Hash for KeyCombination
impl Hash for KeyCombination
source§impl Into<KeyEvent> for KeyCombination
impl Into<KeyEvent> for KeyCombination
source§impl PartialEq for KeyCombination
impl PartialEq for KeyCombination
source§fn eq(&self, other: &KeyCombination) -> bool
fn eq(&self, other: &KeyCombination) -> bool
self
and other
values to be equal, and is used
by ==
.