Skip to content

Commit 114d028

Browse files
committed
Ensure only printable keys added to footer
1 parent a8c3018 commit 114d028

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/textual/keys.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,14 @@ def _get_key_display(key: str) -> str:
245245
return display_alias
246246

247247
original_key = REPLACED_KEYS.get(key, key)
248+
upper_original = original_key.upper().replace("_", " ")
248249
try:
249-
unicode_character = unicodedata.lookup(original_key.upper().replace("_", " "))
250+
unicode_character = unicodedata.lookup(upper_original)
250251
except KeyError:
251-
return original_key.upper()
252+
return upper_original
252253

253-
return unicode_character
254+
# Check if printable. `delete` for example maps to a control sequence
255+
# which we don't want to write to the terminal.
256+
if unicode_character.isprintable():
257+
return unicode_character
258+
return upper_original

0 commit comments

Comments
 (0)