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: 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 more