Replies: 3 comments
-
We found the following entry in the FAQ which you may find helpful: Feel free to close this issue if you found an answer in the FAQ. Otherwise, please give us a little time to review. This project is developed and maintained by Will McGugan. Consider sponsoring Will's work on this project (and others). This is an automated reply, generated by FAQtory |
Beta Was this translation helpful? Give feedback.
-
Here's a simple example. Note that from textual.app import App, ComposeResult
from textual.widgets import Input
class ExampleApp(App):
BINDINGS = [
("ctrl+j", "ctrl_j"),
("ctrl+k", "ctrl_k"),
]
def compose(self) -> ComposeResult:
yield Input("Hello, World!")
def action_ctrl_j(self) -> None:
self.notify("You pressed ctrl+j!")
def action_ctrl_k(self) -> None:
# NOTE: This won't work because `ctrl+k` is an Input binding
self.notify("You pressed ctrl+k!")
if __name__ == "__main__":
app = ExampleApp()
app.run() |
Beta Was this translation helpful? Give feedback.
-
@cyberalt1 Handling key events is not how you create bindings. Please do read the docs on focus and bindings. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
If you try to make a binding that is ctrl + key using the on_key function, it won't work. The only way to bind is to use the arrow keys which is an anti-pattern for the terminal
Beta Was this translation helpful? Give feedback.
All reactions