Skip to main content

classify_key

Function classify_key 

Source
pub fn classify_key(key: &KeyEvent) -> Option<TerminationIntent>
Expand description

Classify a key event into a TerminationIntent, if it is one. Pure, dependency-free function so it’s unit testable without a live terminal/event loop.

  • Bare q / Esc / bare x (no modifiers) -> StopCurrent.
  • Ctrl+C / Ctrl+X (any other modifiers alongside Control, e.g. Shift from a capital-C keycap, still match - contains rather than exact equality) -> QuitAll.
  • Anything else (including Space, and q/x with unrelated modifiers) -> None.