triggerhappy
triggerhappy copied to clipboard
Long press trigger
Hi,
I want to trigger an action after a 3 second press on a button (used as an input key). Do you think Triggerhappy is the correct tool for this usage ? How could I do this ? Maybe there is a contribution to do ?
Thank you,
I think it is doable - you would have to track the keydown and keyup events for that key.
You probably can do a proof of concept without modification to thd. Write a script that touches a file on keydown and a script that checks how far the timestamp of the file is in the past and triggers an action if the key was pressed long enough and bind that to release.
caveat:
- key repeat could repeatedly update the timestamp. So instead you could create/check timestamp on press and check/remove on release
- key repeat usually does not work on multimedia keys so you will get action only after key is released and not after the designated timeout
You can spawn background sleep/check but then you have to be careful to only trigger on long press and not multiple short presses if that would be an issue for your use case.
So, where is the answer how to configure long presses?
you can script it as outlined above.
I think this still might be more elegant if implemented directly at the level of triggerhappy code...
+1, has to be implemented!