From 4383f8f010ef1aa102d96386468997f6c74e81dc Mon Sep 17 00:00:00 2001 From: djarb Date: Wed, 28 Dec 2022 04:11:04 -0800 Subject: [PATCH] Improved F1 through F4 handling (#736) --- src/event/sys/unix/parse.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/event/sys/unix/parse.rs b/src/event/sys/unix/parse.rs index ea2b1b468..0cfbd1a5e 100644 --- a/src/event/sys/unix/parse.rs +++ b/src/event/sys/unix/parse.rs @@ -170,6 +170,13 @@ pub(crate) fn parse_csi(buffer: &[u8]) -> Result> { b'I' => Some(Event::FocusGained), b'O' => Some(Event::FocusLost), b';' => return parse_csi_modifier_key_code(buffer), + // P, Q, and S for compatibility with Kitty keyboard protocol, + // as the 1 in 'CSI 1 P' etc. must be omitted if there are no + // modifiers pressed: + // https://sw.kovidgoyal.net/kitty/keyboard-protocol/#legacy-functional-keys + b'P' => Some(Event::Key(KeyCode::F(1).into())), + b'Q' => Some(Event::Key(KeyCode::F(2).into())), + b'S' => Some(Event::Key(KeyCode::F(4).into())), b'0'..=b'9' => { // Numbered escape code. if buffer.len() == 3 {