Block keyboard input in python

In Python, is there a way to prevent the user from typing anything from the keyboard so that terminal output won't clutter up with unnecessary input?

In my case, the user has to press and hold a key to register a specific keyboard - so the actual input (as in input()

) is not needed, but only clutters the output and menu.

0


source to share


2 answers


I would recommend pygame. http://www.pygame.org/download.shtml It allows you to read all the keyboard keys as you see fit. Here is an example of what the code would look like: How do I get keyboard input in pygame?



0


source


Sounds like you want the terminal content to be redrawn on user input?

https://docs.python.org/3/howto/curses.html or https://docs.python.org/2.7/howto/curses.html depending on python version.



See also this question Dynamically printing terminals with python

0


source







All Articles