From b29be4f1750fd20bd2eada88e751dfae85817882 Mon Sep 17 00:00:00 2001 From: Scott Date: Sat, 4 Dec 2021 21:23:11 -0800 Subject: Various changes. --- input_utils.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'input_utils.py') diff --git a/input_utils.py b/input_utils.py index a989b2d..e0b457d 100644 --- a/input_utils.py +++ b/input_utils.py @@ -2,6 +2,7 @@ """Utilities related to user input.""" +import logging import signal import sys from typing import List @@ -11,6 +12,9 @@ import readchar # type: ignore import exceptions +logger = logging.getLogger(__file__) + + def single_keystroke_response( valid_responses: List[str], *, @@ -34,6 +38,7 @@ def single_keystroke_response( try: while True: response = readchar.readchar() + logger.debug(f'Keystroke: {ord(response)}') if response in valid_responses: break if ord(response) in os_special_keystrokes: @@ -50,6 +55,9 @@ def single_keystroke_response( response = _single_keystroke_response_internal( valid_responses, timeout_seconds ) + if ord(response) == 3: + raise KeyboardInterrupt('User pressed ^C in input_utils.') + except exceptions.TimeoutError: if default_response is not None: response = default_response -- cgit v1.3