pub struct TerminalKey { /* private fields */ }Expand description
A key pressed in a terminal.
It’s important to remember when setting up keybindings and building a TUI that some terminals represent several keypresses the same way by default, while others are capable of precisely representing what keys the user actually pressed, such as when using something like crossterm::event::PushKeyboardEnhancementFlags or when running in Windows terminal.
For example, if you’re using crossterm::event::KeyCode then you’ll likely run into the following in a Unix terminal:
<C-M>will sometimes be represented as<Enter><C-I>will sometimes be represented as<Tab><C-?>will sometimes be represented as<BackSpace><C-@>will sometimes be represented as<C-Space><C-[>will sometimes be represented as<Esc><C-\>will sometimes be represented as<C-4><C-]>will sometimes be represented as<C-5><C-^>will sometimes be represented as<C-6><C-_>will sometimes be represented as<C-7>
You can avoid getting bit by differences between terminals by mapping all of these to the same action for consistency.
Additionally, some modifier keys can’t be expressed by default: <S-Enter> or <C-Enter>
cannot always be represented. If you map those, make sure you also provide alternatives!
Implementations§
Source§impl TerminalKey
impl TerminalKey
Sourcepub fn get_literal_char(&self) -> Option<char>
pub fn get_literal_char(&self) -> Option<char>
Return this key’s representation as a single codepoint, if it exists.
Trait Implementations§
Source§impl Clone for TerminalKey
impl Clone for TerminalKey
Source§fn clone(&self) -> TerminalKey
fn clone(&self) -> TerminalKey
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TerminalKey
impl Debug for TerminalKey
Source§impl Display for TerminalKey
impl Display for TerminalKey
Source§impl From<KeyCode> for TerminalKey
impl From<KeyCode> for TerminalKey
Source§impl From<KeyEvent> for TerminalKey
impl From<KeyEvent> for TerminalKey
Source§impl FromStr for TerminalKey
impl FromStr for TerminalKey
Source§impl Hash for TerminalKey
impl Hash for TerminalKey
Source§impl<I: ApplicationInfo> InputBindings<TerminalKey, InputStep<I>> for EmacsBindings<I>
impl<I: ApplicationInfo> InputBindings<TerminalKey, InputStep<I>> for EmacsBindings<I>
Source§fn setup(&self, machine: &mut EmacsMachine<TerminalKey, I>)
fn setup(&self, machine: &mut EmacsMachine<TerminalKey, I>)
Source§impl<I: ApplicationInfo> InputBindings<TerminalKey, InputStep<I>> for VimBindings<I>
impl<I: ApplicationInfo> InputBindings<TerminalKey, InputStep<I>> for VimBindings<I>
Source§fn setup(&self, machine: &mut VimMachine<TerminalKey, I>)
fn setup(&self, machine: &mut VimMachine<TerminalKey, I>)
Source§impl InputKey for TerminalKey
impl InputKey for TerminalKey
Source§type Error = MacroError
type Error = MacroError
Source§fn decompose(&mut self) -> Option<Self>
fn decompose(&mut self) -> Option<Self>
Source§fn from_macro_str(input: &str) -> Result<Vec<Self>, MacroError>
fn from_macro_str(input: &str) -> Result<Vec<Self>, MacroError>
Source§impl InputKeyClass<TerminalKey> for CommonKeyClass
impl InputKeyClass<TerminalKey> for CommonKeyClass
Source§fn memberships(ke: &TerminalKey) -> Vec<Self>
fn memberships(ke: &TerminalKey) -> Vec<Self>
Source§impl<I: ApplicationInfo> InputKeyState<TerminalKey, CommonKeyClass> for EmacsState<I>
impl<I: ApplicationInfo> InputKeyState<TerminalKey, CommonKeyClass> for EmacsState<I>
Source§fn event(
&mut self,
ev: &EdgeEvent<TerminalKey, CommonKeyClass>,
ke: &TerminalKey,
)
fn event( &mut self, ev: &EdgeEvent<TerminalKey, CommonKeyClass>, ke: &TerminalKey, )
Key has matched an EdgeEvent.Source§fn get_cursor_indicator(&self) -> Option<char>
fn get_cursor_indicator(&self) -> Option<char>
Source§impl<I: ApplicationInfo> InputKeyState<TerminalKey, CommonKeyClass> for VimState<I>
impl<I: ApplicationInfo> InputKeyState<TerminalKey, CommonKeyClass> for VimState<I>
Source§fn event(
&mut self,
ev: &EdgeEvent<TerminalKey, CommonKeyClass>,
ke: &TerminalKey,
)
fn event( &mut self, ev: &EdgeEvent<TerminalKey, CommonKeyClass>, ke: &TerminalKey, )
Key has matched an EdgeEvent.