A few more tweaks to the input code.

This commit is contained in:
Storm Dragon
2025-07-10 01:22:24 -04:00
parent 8ffa53b69f
commit ca2d0d34bd

View File

@ -21,6 +21,7 @@ def get_input(prompt="Enter text:", text=""):
- Up/Down arrows read full text content
- Backspace announces deletions
- Enter submits, Escape cancels
- Control key repeats the original prompt message
- Fully accessible without screen reader dependency
Args:
@ -37,18 +38,10 @@ def get_input(prompt="Enter text:", text=""):
# Announce the prompt and initial text as a single message
if text:
message = f"{prompt} Default text: {text}"
initial_message = f"{prompt} Default text: {text}"
else:
message = f"{prompt} Empty text field"
speak(message)
# Speak initial cursor position
if cursor_pos == 0:
speak("Beginning of text")
elif cursor_pos == len(text_buffer):
speak("End of text")
else:
speak(f"At character: {text_buffer[cursor_pos]}")
initial_message = f"{prompt} Empty text field"
speak(initial_message)
# Main input loop
while True:
@ -121,6 +114,10 @@ def get_input(prompt="Enter text:", text=""):
cursor_pos = len(text_buffer)
speak("End of text")
elif event.key == pygame.K_LCTRL or event.key == pygame.K_RCTRL:
# Repeat the original prompt message
speak(initial_message)
else:
# Handle regular character input
if event.unicode and event.unicode.isprintable():