+ )
+ if yn:
+ yn = yn.lower()
+ return yn
+
+
+def press_any_key(
+ prompt: str = "Press any key to continue...", *, timeout_seconds=None
+) -> Optional[str]:
+ """Press any key to continue..."""
+
+ return single_keystroke_response(None, prompt=prompt, timeout_seconds=timeout_seconds)
+
+
+def up_down_enter() -> Optional[str]:
+ """Respond to UP, DOWN or ENTER events for simple menus without
+ the need for curses."""
+
+ os_special_keystrokes = [3, 26] # ^C, ^Z
+ while True:
+ key = readchar.readkey()
+ if len(key) == 1:
+ if ord(key) in os_special_keystrokes:
+ return None
+ if ord(key) == 13:
+ return 'enter'
+ elif len(key) == 3:
+ if ord(key[0]) == 27 and ord(key[1]) == 91:
+ if ord(key[2]) == 65:
+ return "up"
+ elif ord(key[2]) == 66:
+ return "down"