From 015fe9054e9995609a1c67d3dd4f318f015397b0 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 14 Feb 2021 07:50:54 +0530 Subject: [PATCH] Fix shifted keys not matching shortcuts in kittens Broke after keyboard refactoring for new keyboard protocol. Now a key event will match a shortcut specification if either the mods and key match or mods without shift and shifted key match. Fixes #3314 --- kitty/key_encoding.py | 16 ++++++---------- kitty/key_names.py | 2 -- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/kitty/key_encoding.py b/kitty/key_encoding.py index ce65575a2..35d73ef0d 100644 --- a/kitty/key_encoding.py +++ b/kitty/key_encoding.py @@ -211,18 +211,14 @@ class KeyEvent(NamedTuple): def matches(self, spec: Union[str, ParsedShortcut], types: int = EventType.PRESS | EventType.REPEAT) -> bool: if not self.type & types: return False - q = self.mods - is_shifted = bool(self.shifted_key and self.shift) - if is_shifted: - q = self.mods & ~SHIFT - kq = self.shifted_key - else: - kq = self.key if isinstance(spec, str): spec = parse_shortcut(spec) - if q != spec.mods: - return False - return kq == spec.key_name + if (self.mods, self.key) == spec: + return True + is_shifted = bool(self.shifted_key and self.shift) + if is_shifted and (self.mods & ~SHIFT, self.shifted_key) == spec: + return True + return False def as_window_system_event(self) -> WindowSystemKeyEvent: action = defines.GLFW_PRESS diff --git a/kitty/key_names.py b/kitty/key_names.py index 292e98fe3..a1c62d28e 100644 --- a/kitty/key_names.py +++ b/kitty/key_names.py @@ -50,8 +50,6 @@ character_key_name_aliases = { 'LEFT_BRACKET': '[', 'RIGHT_BRACKET': ']', } -for x in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ': - character_key_name_aliases[x] = x.lower() LookupFunc = Callable[[str, bool], Optional[int]]