I want to (by using Pynput in Python) see if a key is pressed down. For example: while True: if #key alt is pressed down: print("Alt is pressed down")
Asked
Active
Viewed 1,662 times
1 Answers
1
To install pynput in python use following command
pip install pynput
And to check if a key alt is pressed below is my code, for more details refer to the link
from pynput.keyboard import Key, Listener
def on_press(key):
print('{0} pressed'.format(
key))
with Listener(
on_press=on_press) as listener:
listener.join()

Adi.S
- 280
- 1
- 13