How to add hotkey in Python?
I'm making a bot for a game and I want to call the function when I press hotkey. I already tried some solutions but it is not good. Here is my code: def start(): while True: if keyboard.is_pressed('alt+s'): break ... def main(): while True: if keyboard.is_pressed('alt+p'): start() This way is stable but it causes a lag, it is hard for me to type something. def main(): keyboard.add_hotkey('alt+p', start, args=(), suppress=True, trigger_on_release=True) while True: # waiting for the user to press hotkey continue As I know keyboard.add_hotkey only returns output so I can't stop the loop in the st
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.