moses-palmer / pynput

Sends virtual input commands
GNU Lesser General Public License v3.0
1.79k stars 248 forks source link

hotkey with pressing time threshold? #323

Closed mo-han closed 3 years ago

mo-han commented 3 years ago

say i'd like to define a hotkey like <space>(500ms) + h, which means space & h, with space pressed for at least 500ms time. is it possible?

moses-palmer commented 3 years ago

This is certainly possible, but not directly supported by pynput; you would have to implement the logic yourself.

You might for example spawn a threading.Timer when you detect space+h, and cancel it if you receive a release event for space.