Skip to content
Discussion options

You must be logged in to vote

@Sevii

That link is useful. It looks like the answer is that key bindings have to be registered at the App layer. They are ignored at other layers.

This isn't the case. As you'll see throughout our own codebase, and in many Textual applications, keyboard bindings can be created on the App, on a screen or on a widget. The thing to note though is that for a keyboard binding to be able to work on a widget the widget needs to be capable of being focused, and of course the binding only works when the widget has focus.

The same is true for keyboard events too.

You can read about this and more in the guide to input in Textual.

To illustrate all of this, here's a version of your initial example…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Sevii
Comment options

Comment options

You must be logged in to vote
1 reply
@davep
Comment options

Answer selected by davep
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants