keyboard icon indicating copy to clipboard operation
keyboard copied to clipboard

OnPress and OnRelease not working at the same time

Open johmarjac opened this issue 3 years ago • 0 comments

Consider the following script

import keyboard

def onRelease(e):
    print("Released: " + e.name)

def onPress(e):
    print("Pressed: " + e.name)

keyboard.on_press(onPress)
keyboard.on_release(onRelease)

while True:
    import time
    time.sleep(1000)

I expect, OnPress to fire when the key is down and OnRelease to fire when the key is released. Its not doing that for me. If i however uncomment the assign callback function for onPress, onRelease fires. It seems onRelease doesnt fire anymore when onPress is hooked.

Does that make sense`?

johmarjac avatar Aug 17 '21 13:08 johmarjac