triggerhappy icon indicating copy to clipboard operation
triggerhappy copied to clipboard

Long press trigger

Open JGrossholtz opened this issue 8 years ago • 5 comments
trafficstars

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,

JGrossholtz avatar Nov 30 '16 21:11 JGrossholtz

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:

  1. key repeat could repeatedly update the timestamp. So instead you could create/check timestamp on press and check/remove on release
  2. 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.

hramrach avatar Mar 13 '17 14:03 hramrach

So, where is the answer how to configure long presses?

DocMAX avatar Apr 14 '19 06:04 DocMAX

you can script it as outlined above.

hramrach avatar Jul 23 '19 15:07 hramrach

I think this still might be more elegant if implemented directly at the level of triggerhappy code...

Harvie avatar Oct 03 '22 12:10 Harvie

+1, has to be implemented!

DocMAX avatar Feb 19 '24 10:02 DocMAX