Skip to content

Commit 6aab7de

Browse files
committed
fix: Handle backspace in Bash
Bash returns the ASCII code for DELETE instead of BACKSPACE when pressing backspace. Added a special case for that.
1 parent f2f7a30 commit 6aab7de

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

zmk/terminal.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,12 @@ def read_key() -> bytes:
158158
Special keys such as arrow keys return xterm or vt escape sequences.
159159
"""
160160
with disable_echo():
161-
return os.read(sys.stdin.fileno(), 4)
161+
key = os.read(sys.stdin.fileno(), 4)
162+
163+
if key == b"\x7f": # Bash uses DELETE instead of BACKSPACE
164+
return BACKSPACE
165+
166+
return key
162167

163168

164169
def get_cursor_pos() -> tuple[int, int]:

0 commit comments

Comments
 (0)