0

I want to make a project which is a bit like a quiz. I want to make it so that instead of typing Y the pressing Enter, I want it to be you press the Y key on your keyboard and wait 5 seconds before the terminal automatically accepts it.

Lordcobcob
  • 20
  • 6

1 Answers1

1

This sounds like you want to read keyboard input. I would check out this page: https://www.delftstack.com/howto/python/python-detect-keypress/

There is a module to detect keyboard input. They also post a nice example:

import keyboard

while True:
    if keyboard.read_key() == "p":
        print("You pressed p")
        break

while True:
    if keyboard.is_pressed("q"):
        print("You pressed q")
        break
        
keyboard.on_press_key("r", lambda _:print("You pressed r"))
dominic
  • 367
  • 2
  • 5