3

While sleeping, I want all keyboard input to be ignored.

I tried this:

time.sleep(10)
while msvcrt.kbhit():
    flush = input()
input_code = input()

It doesn't work.

2
  • Could be similar to stackoverflow.com/questions/29523657/… Commented Jun 29, 2019 at 21:56
  • There is a good example on Rosetta Code on how to flush the keyboard buffer. It uses the msvcrt module as well Commented Jun 29, 2019 at 22:35

1 Answer 1

0

It should be msvcrt.getch() inside the loop, not input():

time.sleep(10)
while msvcrt.kbhit():
    msvcrt.getch()
input_code = input()
Sign up to request clarification or add additional context in comments.

1 Comment

Can you describe more precisely what happens?

Your Answer

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.