If I hold down a key, can I make it type a different keystroke compared to tapping it?

Hello! I'm a new user coming from Controllermate (it's not compatible with Catalina) and KM does things so differently I need some help to achieve what I'm trying to do.

I'm using an X-Keys controller and want to be able to do two functions with one button. Specifically two different keystrokes. One when I press it like a normal button, and another when I hold it down for a given amount of time (0.5 seconds for example).

My biggest issue is canceling the first function from happening once I hold down the button to get the second one.

Any help would be greatly appreciated. Thanks!

One thing you could try is setting a timestamp variable upon activating the macro, pausing the macro until the button used to execute the macro is up/no longer being pressed, then subtract the timestamp variable from the current time and have the macro do different things depending on whether the result is shorter than the desired time:

Example - Branch Actions by Key Press Time.kmmacros (3.0 KB)


Thanks for the prompt reply gglick. I have imported your macro and it looks good but the problem I have is that I'm using a USB device other than a regular keyboard (X-Keys controller) and while I can choose a specific "device key" of my USB device on the very beginning of the macro, there is no way to add that device key in the "Pause until conditions are met" action. I've looked at all the options and I can't find anything that gives me that functionality.

In short, I want to press button C6 on my USB controller and if it's less than half a second to do a "T" keystroke and if it's more than half a second, to do a "command+F" keystroke.