Skip to main content

encode_key

Function encode_key 

Source
pub fn encode_key(ev: KeyEvent) -> Option<EncodedKey>
Expand description

Translate a crossterm KeyEvent to the form tmux send-keys expects. Returns None for keys we deliberately drop (release events on kitty-protocol terminals, modifier-only presses).

Convention:

  • Plain printable chars → -l <char> (literal, sidesteps tmux’s key-name parsing on tokens like ; or ~).
  • Modifier combos and named keys → tmux key-name form (C-c, M-x, S-Tab, Enter, BSpace, Up, F4, …).
  • Shift on a printable char is already reflected in the char itself (crossterm gives Char('A') for shift+a), so S- is only emitted for named keys (S-Tab, S-Up).