diff options
Diffstat (limited to 'input_utils.py')
| -rw-r--r-- | input_utils.py | 8 |
1 files changed, 8 insertions, 0 deletions
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 |
