It is necessary to make sure that during a certain period of time they are not available for pressing a certain key, for example Space. So that during a break, user clicks are not displayed in any way in the input(). Please suggest a module or a complete solution. Example:
import time
time.sleep(5) # So that during this period of time nothing could be written.
enter = input()
-
Do you mean the key that the user is pressing doesn't effect your python program?HoneyPoop– HoneyPoop2020年11月29日 06:59:33 +00:00Commented Nov 29, 2020 at 6:59
-
Yes, but only while waiting. But after it was over, I read it as in normal mode.Jogim– Jogim2020年11月29日 07:07:45 +00:00Commented Nov 29, 2020 at 7:07
-
Ok, I will upload an answer I think just might helpHoneyPoop– HoneyPoop2020年11月29日 07:08:20 +00:00Commented Nov 29, 2020 at 7:08
1 Answer 1
welcome to SO! Your description is very vague, but assuming you want to prevent a specific keystroke from affecting your program for 5 seconds, this might just work:
import keyboard
import time
time_end = time.time() + 5
while time.time() < time_end:
if keyboard.is_pressed('q'):
pass
replace 'q' with the key you don't want to affect your program. Wherever "pass" is is what will happen if q is pressed within those seconds. I think q will still show up in your program when it's pressed, but wont affect any of your other functions unless you have threading. Sorry if this doesn't help, this is the only thing I could think of.