Files
textual/docs/examples/guide/input/key02.py
Will McGugan 3f0955cbe5 fix tests
2022-09-26 09:51:33 +01:00

22 lines
444 B
Python

from textual.app import App, ComposeResult
from textual.widgets import TextLog
from textual import events
class InputApp(App):
"""App to display key events."""
def compose(self) -> ComposeResult:
yield TextLog()
def on_key(self, event: events.Key) -> None:
self.query_one(TextLog).write(event)
def key_space(self) -> None:
self.bell()
if __name__ == "__main__":
app = InputApp()
app.run()