mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-27 18:51:41 +02:00
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
This commit is contained in:
16
kitty/key_encoding.py
generated
16
kitty/key_encoding.py
generated
@@ -211,18 +211,14 @@ class KeyEvent(NamedTuple):
|
|||||||
def matches(self, spec: Union[str, ParsedShortcut], types: int = EventType.PRESS | EventType.REPEAT) -> bool:
|
def matches(self, spec: Union[str, ParsedShortcut], types: int = EventType.PRESS | EventType.REPEAT) -> bool:
|
||||||
if not self.type & types:
|
if not self.type & types:
|
||||||
return False
|
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):
|
if isinstance(spec, str):
|
||||||
spec = parse_shortcut(spec)
|
spec = parse_shortcut(spec)
|
||||||
if q != spec.mods:
|
if (self.mods, self.key) == spec:
|
||||||
return False
|
return True
|
||||||
return kq == spec.key_name
|
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:
|
def as_window_system_event(self) -> WindowSystemKeyEvent:
|
||||||
action = defines.GLFW_PRESS
|
action = defines.GLFW_PRESS
|
||||||
|
|||||||
@@ -50,8 +50,6 @@ character_key_name_aliases = {
|
|||||||
'LEFT_BRACKET': '[',
|
'LEFT_BRACKET': '[',
|
||||||
'RIGHT_BRACKET': ']',
|
'RIGHT_BRACKET': ']',
|
||||||
}
|
}
|
||||||
for x in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
|
|
||||||
character_key_name_aliases[x] = x.lower()
|
|
||||||
LookupFunc = Callable[[str, bool], Optional[int]]
|
LookupFunc = Callable[[str, bool], Optional[int]]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user