rvaiya / keyd

A key remapping daemon for linux.
MIT License
2.98k stars 175 forks source link

[Advice needed] How to implement Push-to-talk like behavior #661

Open kvj opened 9 months ago

kvj commented 9 months ago

Hi,

I swear I've spent quite some amount of time reading documentation and trying things out. How can I implement the following behavior?

a single press will emit C-d, but press and hold will emit C-d on press start and C-d on press finish. The idea is to toggle Mic with short press and turn it on and then off for long press.

Any advice is much apreciated

rvaiya commented 9 months ago

I don't believe this is possible with the current feature set. If I understand you correctly, you effectively want to simulate a key press on key release.

This feels like something that should be built into the recording software, and I can't think of too many instances in which it would be generally desirable, but I am willing to consider the addition of such an action if you can make a case for it.

If you are really desperate, you can probably hack together a shell script to do this using a combination of keyd monitor and keyd input, but I wouldn't recommend it :P.

kvj commented 9 months ago

Thanks for the response!

Hacking is definitely possible. I was thinking about something like *layerm(<layer>, <macro>)* but with two macro: one before layer change, another after

Update: it's actually working approach

rvaiya commented 9 months ago

Before proceeding, it would be preferable if you could precisely outline the action you are proposing as well as the class of problems it solves.

At the moment, the use case seem fairly niche, and I tend to take a conservative approach to new features. I am not yet persuaded that having a dedicated action which does something on key up is warranted.

tkna91 commented 9 months ago

Let me make a request as well.

I would like to use something like this to turn my computer keyboard into a virtual MIDI keyboard.

To do this, I need to have it execute a NOTE OFF command when the key is up.

Something like this already exists, but to enter MIDI on a computer keyboard requires focus on the GUI window, which makes it difficult to concentrate on the operation seamlessly.

https://vmpk.sourceforge.io/

it would be very smart if it could be done in keyd.

tkna91 commented 9 months ago

The basic idea would be that key down would execute a key or command to enable/open some function, and key up would execute a key or command to disable/close it, but it could be used in a variety of ways, such as the following.

It is fascinating to be able to complete start and finish with a single key. I think it would make things much easier by lowering the cognitive load for many things.