From 51545ab0992608d48142bbb2e05f6dcef8b200b3 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Fri, 17 Jan 2020 16:56:29 -0800 Subject: [PATCH] termwiz: windows: normalize SHIFT+ASCII This makes the input behavior consistent with posix: if SHIFT is held and a letter key is pressed, make sure that we treat that as the ascii uppercase version of that key and that the SHIFT modifier is cleared. --- termwiz/src/input.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/termwiz/src/input.rs b/termwiz/src/input.rs index 44a118a55..c738da2ba 100644 --- a/termwiz/src/input.rs +++ b/termwiz/src/input.rs @@ -370,7 +370,14 @@ mod windows { _ => return, }, }; - let modifiers = modifiers_from_ctrl_key_state(event.dwControlKeyState); + let mut modifiers = modifiers_from_ctrl_key_state(event.dwControlKeyState); + + let key_code = key_code.normalize_shift_to_upper_case(modifiers); + if let KeyCode::Char(c) = key_code { + if c.is_ascii_uppercase() { + modifiers.remove(Modifiers::SHIFT); + } + } let input_event = InputEvent::Key(KeyEvent { key: key_code,