I'm making a typing speed test game and trying to make it so that when a user is typing into a python input(), it can be submitted by them pressing space rather than just enter, on Windows. My code is similar to the following:
score = 0
start_time = int(time.time())
characters = 0
words = 0
current_word = random.choice(WORDS)
next_word = random.choice(WORDS)
while (int(time.time()) - start_time) <= TIME_LIMIT:
os.system('cls')
print(f"Your word is {current_word}")
print(f"The next word will be {next_word}")
print(f"Your current score is {score}")
attempt = input("> ")
if attempt.lower() == current_word.lower():
score = score + 1
words = words + 1
characters = characters + len(current_word)
current_word = next_word
next_word = random.choice(WORDS)
Is there any way for this to work or is it best to maybe create my own input function?