Search code examples
python-3.xpyautoguipynput

With which library I can bind hotkeys in python code?


I have a function and I want to bind this function to "ctrl"+"alt". I already used pynput, but it reacts even on typical "ctrl" or "alt". How to realize it in...more comfortable way? I tried pyautogui, but it too cause some strange things if I'm not mistaken.

     from pynput import keyboard
     with keyboard.GlobalHotKeys({'<ctrl>+<alt>': pognali}) as k:
         k.join()

Solution

  • This works very good!

        import keyboard
        keyboard.add_hotkey('ctrl+alt', pognali)