summaryrefslogtreecommitdiff
path: root/input_utils.py
diff options
context:
space:
mode:
authorScott <[email protected]>2021-12-04 21:23:11 -0800
committerScott <[email protected]>2021-12-04 21:23:11 -0800
commitb29be4f1750fd20bd2eada88e751dfae85817882 (patch)
treed776c05519505fa3234ed44ae952163f0853e88c /input_utils.py
parented8fa2b10b0177b15b7423263bdd390efde2f0c8 (diff)
Various changes.
Diffstat (limited to 'input_utils.py')
-rw-r--r--input_utils.py8
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