From 33eb1dd45e18360be203f82a96f22b7ce70be06f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Wed, 13 May 2026 20:16:33 +0200 Subject: [PATCH] add modifier keys --- bin/kitty_keytester.py | 12 ++-- .../german_qwertz_no_modifier.json | 70 +++++++++++++++++++ 2 files changed, 76 insertions(+), 6 deletions(-) diff --git a/bin/kitty_keytester.py b/bin/kitty_keytester.py index 073c34d1c..1575d3bb2 100644 --- a/bin/kitty_keytester.py +++ b/bin/kitty_keytester.py @@ -25,7 +25,7 @@ class TerminalContext: return TerminalContext(fd, True) def close(self) -> None: - tcsetattr(self.fd, TCSAFLUSH, self._initial_attr) + tcsetattr(self.fd, TCSADRAIN, self._initial_attr) if self.close_fd: os.close(self.fd) @@ -47,11 +47,11 @@ class TerminalContext: return tattr = self.termios_attributes try: - setcbreak(self.fd, TCSAFLUSH) + setcbreak(self.fd, TCSADRAIN) self.is_cbreak = True yield finally: - tcsetattr(self.fd, TCSAFLUSH, tattr) + tcsetattr(self.fd, TCSADRAIN, tattr) self.is_cbreak = False @contextmanager @@ -64,11 +64,11 @@ class TerminalContext: return tattr = self.termios_attributes try: - setraw(self.fd, TCSAFLUSH) + setraw(self.fd, TCSADRAIN) self.is_raw = True yield finally: - tcsetattr(self.fd, TCSAFLUSH, tattr) + tcsetattr(self.fd, TCSADRAIN, tattr) self.is_raw = False @contextmanager @@ -139,7 +139,7 @@ def extract_events(data: list[str]): def query(term: TerminalContext, mode: int): with term.custom_state(undo=lambda:term.write('\x1b[{mode}u') - sleep(.1) + term.read(timeout=.1) print('PRESS (within 5s) and HOLD (for 5s)\r') data: list[bytes] = [] cur = term.read(timeout=5) diff --git a/fixtures/kitty_keyboard/german_qwertz_no_modifier.json b/fixtures/kitty_keyboard/german_qwertz_no_modifier.json index 00bb9c9fe..472f939dd 100644 --- a/fixtures/kitty_keyboard/german_qwertz_no_modifier.json +++ b/fixtures/kitty_keyboard/german_qwertz_no_modifier.json @@ -628,5 +628,75 @@ "REPEAT": "\u001b[57426u", "RELEASE": null } + }, + "Numlock": { + "1": { + "PRESS": null, + "REPEAT": null, + "RELEASE": null + } + }, + "CapsLock": { + "1": { + "PRESS": null, + "REPEAT": null, + "RELEASE": null + } + }, + "Shift (ShiftLeft)": { + "1": { + "PRESS": null, + "REPEAT": null, + "RELEASE": null + } + }, + "Shift (ShiftRight)": { + "1": { + "PRESS": null, + "REPEAT": null, + "RELEASE": null + } + }, + "Control (ControlLeft)": { + "1": { + "PRESS": null, + "REPEAT": null, + "RELEASE": null + } + }, + "Meta (MetaLeft)": { + "1": { + "PRESS": null, + "REPEAT": null, + "RELEASE": null + } + }, + "Alt (AltLeft)": { + "1": { + "PRESS": null, + "REPEAT": null, + "RELEASE": null + } + }, + " (Space)": { + "1": { + "PRESS": " ", + "REPEAT": " ", + "RELEASE": null + } + }, + "AltGraph (AltRight)": { + "1": { + "PRESS": null, + "REPEAT": null, + "RELEASE": null + } + }, + "Control (ControlRight)": { + "1": { + "PRESS": null, + "REPEAT": null, + "RELEASE": null + } } } \ No newline at end of file