pub fn key_to_bytes(key: KeyEvent) -> Vec<u8> ⓘExpand description
Translate a crossterm KeyEvent into the raw byte sequence the
remote device sees. Returns an empty Vec for events that do not
correspond to a byte on the wire (e.g. modifier-only presses).
Semantics:
Ctrl-<letter>→0x01..=0x1a(e.g. Ctrl-A →0x01).- Plain
KeyCode::Char→ UTF-8 encoding of that character. KeyCode::Enter→CR(0x0d), matching picocom’s default “send CR on Enter” behaviour. Line-ending translation (CR → CRLF etc.) is the mapper’s job (Issue #8), not ours.KeyCode::Tab→HT(0x09).KeyCode::Backspace→DEL(0x7f), again matching picocom.KeyCode::Esc→ESC(0x1b).- Anything else (arrows, function keys, modifier-only) returns
an empty
Vec. T14+ can grow CSI sequences if a real use case surfaces.