key!() { /* proc-macro */ }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:
let key_event = crossterm::event::KeyEvent {
modifiers: crossterm::event::KeyModifiers::CONTROL,
code: crossterm::event::KeyCode::Char('\u{63}'),
};Keys which can’t be valid identifiers in Rust must be put between simple quotes:
let ke = key!(shift-'?');
let ke = key!('5');
let ke = key!(alt-']');