Skip to content
Discussion options

You must be logged in to vote

Binding a different key to call quit won't override any other binding for the same action, so that won't remove the binding for Ctrl+C. What you could do is bind it to an action that does nothing:

from textual.app import App, ComposeResult
from textual.binding import Binding
from textual.widgets import Label

class QuitApp(App[None]):

    BINDINGS = [
        Binding("ctrl+q", "quit"),
        Binding("ctrl+c", "do_not_quit"),
    ]

    def compose(self) -> ComposeResult:
        yield Label("Press Ctrl+Q to quit, don't press Ctrl+C!")

    def action_do_not_quit(self) -> None:
        pass

if __name__ == "__main__":
    QuitApp().run()

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Tim-Cao
Comment options

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