Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/textual/_xterm_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,10 @@ def _sequence_to_key_events(
# If the sequence mapped to a tuple, then it's values from the
# `Keys` enum. Raise key events from what we find in the tuple.
for key in keys:
yield events.Key(key.value, sequence if len(sequence) == 1 else None)
key_name = key.value
if alt:
key_name = f"alt+{key_name}"
yield events.Key(key_name, sequence if len(sequence) == 1 else None)
return
# If keys is a string, the intention is that it's a mapping to a
# character, which should really be treated as the sequence for the
Expand Down
2 changes: 2 additions & 0 deletions tests/test_xterm_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ def test_double_escape(parser):
("\x1b[65;4u", "alt+shift+a"),
("\x1bA", "alt+shift+a"),
("\x1b[120;7u", "alt+ctrl+x"),
("\x1b\r", "alt+enter"),
("\x1b ", "alt+space"),
],
)
def test_keys(parser, sequence: str, key: str) -> None:
Expand Down