macro_rules! key {
    ($($tt:tt)*) => { ... };
}
Expand description

check and expand at compile-time the provided expression into a valid KeyEvent.

For example:

let key_event = key!(ctrl-c);

is expanded into (roughly):

let key_event = crossterm::event::KeyEvent {
    modifiers: crossterm::event::KeyModifiers::CONTROL,
    code: crossterm::event::KeyCode::Char('c'),
};

Keys which can’t be valid identifiers or digits in Rust must be put between simple quotes:

let ke = key!(shift-'?');
let ke = key!(alt-']');