Closed HWTsang closed 1 year ago
I press ctrl+e, ctrl+r and ctrl+t respectively. My expectation is
1 1 end 2 2 end 3 3 end
But the actual result is
1 1 end 2 2 end 2 2 end 3 3 end
windows11 pynput1.7.6
import time from pynput import keyboard def replay(sec: int): def wrap(): print(sec) time.sleep(sec) print(sec, 'end') return wrap keys = {'<ctrl>+e': replay(1), '<ctrl>+r': replay(2), '<ctrl>+t': replay(3)} global_hotkeys = keyboard.GlobalHotKeys(keys) global_hotkeys.start() while True: time.sleep(1)
Thank you for your report.
Please consult the documentation; long running tasks must not be executed in the event callbacks. Your script works if you remove the time.sleep call.
time.sleep
I press ctrl+e, ctrl+r and ctrl+t respectively. My expectation is
But the actual result is
windows11 pynput1.7.6