Skip to content

Commit 7393fea

Browse files
committed
bugfix kitty keyboard ^C and ^D to work again
1 parent ae4ebab commit 7393fea

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

gambaterm/run.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,15 @@ def run(
121121
# so that detection is keyboard-layout agnostic: e.g. a Bépo user
122122
# presses Ctrl+C (physically Ctrl+H on US layout) and the terminal
123123
# translates it to \x03 (ETX) before putting it on stdin.
124-
# For blessed backend: keystrokes were collected during get_input()
124+
# For blessed backend: keystrokes were collected during get_input().
125+
# With kitty protocol, ctrl+c arrives as an enhanced CSI sequence
126+
# (e.g. \x1b[99;5u) rather than raw \x03, so we also check blessed's
127+
# decoded key_name attribute.
125128
if isinstance(get_input, GameInputGetter) and get_input.cpr_state.keystrokes:
126129
for key in get_input.cpr_state.keystrokes:
127-
if str(key) == "\x03":
130+
if str(key) == "\x03" or key.key_name == "KEY_CTRL_C":
128131
raise KeyboardInterrupt
129-
if str(key) == "\x04":
132+
if str(key) == "\x04" or key.key_name == "KEY_CTRL_D":
130133
raise OSError
131134
# For X11/pynput backends: game input comes from X11 events / OS key
132135
# hooks (not stdin), so we read stdin here solely for ctrl-c/ctrl-d.

0 commit comments

Comments
 (0)