From 3a9d1430d45e8d7d8b47c348e9bcc10720791b3c Mon Sep 17 00:00:00 2001 From: rhysd Date: Sat, 3 Aug 2024 23:48:30 +0900 Subject: [PATCH] caveat on conversion from termion's key event into `Input` (#68) --- src/input/termion.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/input/termion.rs b/src/input/termion.rs index a495030..2fabeb1 100644 --- a/src/input/termion.rs +++ b/src/input/termion.rs @@ -14,6 +14,13 @@ impl From for Input { impl From for Input { /// Convert [`termion::event::Key`] into [`Input`]. + /// + /// termion does not provide a way to get Shift key's state. Instead termion passes key inputs as-is. For example, + /// when 'Shift + A' is pressed with US keyboard, termion passes `termion::event::Key::Char('A')`. We cannot know + /// how the 'A' character was input. + /// + /// So the `shift` field of the returned `Input` instance is always `false` except for combinations with arrow keys. + /// For example, `termion::event::Key::Char('A')` is converted to `Input { key: Key::Char('A'), shift: false, .. }`. fn from(key: KeyEvent) -> Self { let (ctrl, alt, shift) = match key { KeyEvent::Ctrl(_)