Skip to main content

Module keys

Module keys 

Source
Expand description

The crossterm → KeyInput translation boundary (Slice 2, #3414).

Why: Slice 1 (#3412) defined KeyInput/KeyCode/KeyModifiers as a deliberately crossterm-free vocabulary so ReplEvent (and every TuiEngine consumer) never needs the crossterm dependency — only the terminal layer itself does. This module is that one translation point: spawn_key_reader in crate::run calls translate_key_event exactly once, at the moment a real crossterm::event::KeyEvent comes off the blocking reader thread, so every line of code past that point (the shared event loop, both TuiEngine implementations, and eventually the Slice 4 widgets) only ever sees KeyInput.

What: a pure, allocation-free mapping from crossterm::event::{KeyCode, KeyModifiers} to their crate::event counterparts. KeyCode::Other (Slice 1’s deliberate catch-all) absorbs every crossterm variant the line editor doesn’t switch on (F-keys, media keys, KeyCode::Null, …) so this mapping never needs to change shape just because crossterm adds a new key variant upstream.

§Spec References

Functions§

translate_key_event
Translate one crossterm::event::KeyEvent into a KeyInput.