pkutp
pkutp

Reputation: 11

pynput keyboard GlobalHotKeys respond to other keys

keyboard.GlobalHotKeys from pynput are responding to incorrect key that is not registered.

I tried to register global hot keys in python. It works fine for the first time but after that it responds to incorrect keys like ctrl+alt without w/e.

Beep is not the cause. It happens without winsound.

from pynput import keyboard
import winsound

def f():
    winsound.Beep(300,500)

hotkeyHandlers = {
    '<ctrl>+<alt>+w': f,
    '<ctrl>+<alt>+e': f,
    # '<ctrl>+1': f,
    # '<ctrl>+2': f,
    # '<ctrl>+3': f,
    # '<ctrl>+4': f,
    # '<ctrl>+5': f,
}

with keyboard.GlobalHotKeys(hotkeyHandlers) as h:
    h.join()

Upvotes: 0

Views: 15

Answers (0)

Related Questions