Guest User

Untitled

a guest
May 23rd, 2022
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. import keyboard  # using module keyboard
  2. while True:  # making a loop
  3.     try:  # used try so that if user pressed other than the given key error will not be shown
  4.         if keyboard.is_pressed('q'):  # if key 'q' is pressed
  5.             print('You Pressed Q')
  6.             break  # finishing the loop
  7.     except:
  8.         break
Advertisement
Add Comment
Please, Sign In to add comment