diff --git a/CHANGELOG.md b/CHANGELOG.md index bd794d3..16bddc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +- Ignore spurious `ctrl+@` keys generated by Windows. (See [textualize/textual#872](https://github.com/Textualize/textual/issues/872)). + ## [0.9.4] - 2023-12-18 - No longer show bindings in the footer when the open or save inputs are focussed. diff --git a/src/textual_textarea/textarea.py b/src/textual_textarea/textarea.py index c262998..bf7c8ce 100644 --- a/src/textual_textarea/textarea.py +++ b/src/textual_textarea/textarea.py @@ -227,6 +227,15 @@ def on_focus(self) -> None: self.undo_timer.reset() def on_key(self, event: events.Key) -> None: + # Naked shift or ctrl keys on Windows get sent as NUL chars; Textual + # interprets these as `ctrl+@` presses, which is inconsistent with + # other platforms. We ignore these presses. + # https://github.com/Textualize/textual/issues/872 + if event.key == "ctrl+@": + event.stop() + event.prevent_default() + return + self.undo_timer.reset() if event.key in ( "apostrophe",