Repository: Textualize/textual

Issue:
Binding for `]` renders incorrectly in `Footer`
The binding `Binding("ctrl+right_square_bracket", "toggle_indent_width", "Cycle indent width")` renders like this:

<img width="431" alt="image" src="https://github.com/Textualize/textual/assets/5740731/2c2bd6fa-288b-4205-aba0-48eb1b6c41e0">

It should probably render as `Ctrl+]`.

Discussion:
TomJGooding: Alternatively here's a quick test with spaces around the plus sign to make it less cramped:

![image](https://github.com/Textualize/textual/assets/101601846/08a77423-6b98-4d7d-b5fb-75bc05f214bf)

Either way, I think it would be an improvement on `CTRL+RIGHT_SQUARE_BRACKET`!

TomJGooding: I've merged main again to resolve changelog conflicts, but not added a new entry yet for this fix.
TomJGooding: No problem, I think just this PR fell between the cracks where I didn't to bother you by chasing but then forgot about it myself until today!

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 705eb5dd3..8019a5f1b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -43,6 +43,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
 - Ensuring `TextArea.SelectionChanged` message only sends when the updated selection is different https://github.com/Textualize/textual/pull/3933
 - Fixed declaration after nested rule set causing a parse error https://github.com/Textualize/textual/pull/4012
 - ID and class validation was too lenient https://github.com/Textualize/textual/issues/3954
+- Fixed display of keys when used in conjunction with other keys https://github.com/Textualize/textual/pull/3050
 
 ## [0.47.1] - 2023-01-05
 
@@ -437,7 +438,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
 
 ## [0.33.0] - 2023-08-15
 
-
 ### Fixed
 
 - Fixed unintuitive sizing behaviour of TabbedContent https://github.com/Textualize/textual/issues/2411
diff --git a/src/textual/keys.py b/src/textual/keys.py
index ef32404d1..36da438d2 100644
--- a/src/textual/keys.py
+++ b/src/textual/keys.py
@@ -283,6 +283,9 @@ def _get_key_display(key: str) -> str:
     """Given a key (i.e. the `key` string argument to Binding __init__),
     return the value that should be displayed in the app when referring
     to this key (e.g. in the Footer widget)."""
+    if "+" in key:
+        return "+".join([_get_key_display(key) for key in key.split("+")])
+
     display_alias = KEY_DISPLAY_ALIASES.get(key)
     if display_alias:
         return display_alias


Test patch:
diff --git a/tests/test_keys.py b/tests/test_keys.py
index 9f13e17d1..3aac179fc 100644
--- a/tests/test_keys.py
+++ b/tests/test_keys.py
@@ -52,3 +52,20 @@ async def test_character_bindings():
 
 def test_get_key_display():
     assert _get_key_display("minus") == "-"
+
+
+def test_get_key_display_when_used_in_conjunction():
+    """Test a key display is the same if used in conjunction with another key.
+    For example, "ctrl+right_square_bracket" should display the bracket as "]",
+    the same as it would without the ctrl modifier.
+
+    Regression test for #3035 https://github.com/Textualize/textual/issues/3035
+    """
+
+    right_square_bracket = _get_key_display("right_square_bracket")
+    ctrl_right_square_bracket = _get_key_display("ctrl+right_square_bracket")
+    assert ctrl_right_square_bracket == f"CTRL+{right_square_bracket}"
+
+    left = _get_key_display("left")
+    ctrl_left = _get_key_display("ctrl+left")
+    assert ctrl_left == f"CTRL+{left}"