1

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()
asked Nov 29, 2020 at 6:45
3
  • Do you mean the key that the user is pressing doesn't effect your python program? Commented Nov 29, 2020 at 6:59
  • Yes, but only while waiting. But after it was over, I read it as in normal mode. Commented Nov 29, 2020 at 7:07
  • Ok, I will upload an answer I think just might help Commented Nov 29, 2020 at 7:08

1 Answer 1

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.

answered Nov 29, 2020 at 7:13
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.