From 2aec07601583c79b08db32dea37d010f462c6644 Mon Sep 17 00:00:00 2001 From: Daniel Edgecumbe Date: Wed, 27 Sep 2017 22:17:32 +0100 Subject: [PATCH] [keypress] Let 'q' quit, and disable quitting for all other keys. --- main.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 6d549de..ecf917f 100644 --- a/main.py +++ b/main.py @@ -26,10 +26,13 @@ async def keypress_loop(window, callback, resize_callback): await resize_callback(y, x) return + if len(key) == 1 and key.lower() == "q": + raise Exception("Quitting.") + key = await callback(key) if key is not None: - # hand off key to somewhere else. - raise Exception + # Unhandled key. Don't care. + pass first = True while True: