I need to do roughly the following:
while True:
if *a key is pressed within 5 seconds of some prior event*:
print(*the specific key that was pressed)
elif *5 seconds pass with no key press*
print("No key pressed")
I posted about my specific needs in another question (Read specific key with msvcrt.getch() OR move on after set time with no input), but I figure this format is much more approachable. The critical part here is that I must know what key was pressed. I have been trying to use msvcrt.getch() amd msvcrt.kbhit(), but it seems I need some sort of hybrid.
Can anyone figure this out?
Windows 11, Python 3.11.0