diff --git a/src/textual/_xterm_parser.py b/src/textual/_xterm_parser.py index 1b7f3e57d9..53af7cab0b 100644 --- a/src/textual/_xterm_parser.py +++ b/src/textual/_xterm_parser.py @@ -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 diff --git a/tests/test_xterm_parser.py b/tests/test_xterm_parser.py index 28a002f2e6..77bc8a188a 100644 --- a/tests/test_xterm_parser.py +++ b/tests/test_xterm_parser.py @@ -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: