Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Python's keyboard library need super user on Linux but not on Windows

recently I have made a CLI program using Python and it uses a library called keyboard. The program is working very well but have something that hurts me…

For any reason when I start it in Windows works normally, but on Linux (probably on MacOS too) gives a error of permission. What i know about this library is that it captures the keys even when the terminal windows is inactive, maybe the Linux think this dangerous and ask for super user. I particularly don’t care to get the user "keypressers" even when the terminal window is inactive (Only in active terminal is great for me)

then I looked for some libraries similar this one, but for any reason don’t work pretty similar. the keyboard library has a function called is_pressed() that returns a boolean value based if a specific key is pressed, for example: if is_pressed('space'), but I didn’t find a alternative library that have a similar function.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Assuming this is for a game, you might want to take a look at the pygame framework. It has an eventloop specifically for this kind of purpose. Docs here.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading