Short Press Shortcut Do One Action, Long Press Do Something Else

TBD psuedo long press if J key is held down Macro (v10.0)

TBD psuedo long press if J key is held down.kmmacros (3.5 KB)

1 Like

Edit: see simplified version, a few comments below. It works better while typing quickly.


This works very reliably for me.

Type "J" or Do Something Else.kmmacros (88 KB)

Macro screenshot

Based on the hotkey version of THIS.

1 Like

This is nice. The macro is reliable in itself, but the problem is always the same. It fails when writing fast.

Instead of "jeep" it types "ejep".

1 Like

Yep, confirmed. Hadn't thought of typing fast. Ah well.

The reason for this, seems clear to me. The command "j" (short pressed) would have to be given at "pressed", not at "released". And be deleted again if the key is held longer. This is the "logical" solution, but probably not doable in practice. :man_shrugging: Or what do you think?

The reason, as I see it, is that the processes in the previous macro I posted take too long and interrupt fast typing. That's because I used the full version of the macro, which has all sorts of other options. Here's a version with all that stuff stripped away, and it seems to work well when typing "jeep" as fast as my fingers can manage it.

Type "J" or Do Something Else.kmmacros (47 KB)

Macro screenshot

Let me try it with my fingers :slight_smile:

Sorry, no difference :frowning: I am convinced that it has something to do with "released".

Well there is a difference, but evidently not enough of one to make it bulletproof on your system.

I can't get it to trip up here, so I'm wondering if your mac runs at a different speed; I'm on a 2.4GHz i9.

I have no idea at what speed my M1 Air runs. But I learned many years ago to write fast with 10 fingers :slight_smile:

I think the problem is systemic. Because of the „if“ KM has to distinguish between two actions… Why? Typing J should not be the task of KM.

KM should only have to measure the time and perform one action when that time is exceeded.

J is pressed for less than 1 s. KM only "observes" and does nothing. J is processed by macos.

J is pressed for longer than 1 s, KM intervenes and does something.

This is of course expressed in layman's terms :slight_smile:

I still suspect it's more to do with your mac, as I'm hammering out "jeep" and "jjjjjjjjjj" at break-neck speed without issue... And I'm a drummer. :joy:

As part of detecting the press and release of the "J" key in a standalone macro.

The trouble is, KM "eats" the keypress , so if you want to use J as a hotkey and type J at the same time, you have to simulate pressing "J" as part of the macro.

KM would already have to be aware of the keypress, so J has to be the hotkey. See what I mean?

If you can think of a better solution, I'm all ears.

While a drummer writes "jeep", I bought one long ago. :joy: :rofl: :innocent:

Seriously, your macro is very useful for keys that are not needed in daily writing in rapid succession.

I'd be interested to know whether it works for other people or they get the same result as you.

Mh … What I do not understand. When I press the letter "a" normally while writing, the system makes an "a". Of course, what else? The "a" is typed when the key is down, not up (released).

If I press "a" and hold it, this menu appears
image

Isn't this exactly the same short/long press action? Why does this work here without interference?

Good point!

Hey Frank,

This is the accent menu in macOS that Apple so kindly added and didn't provide a proper system preference for.

Older versions of macOS:

defaults write -g ApplePressAndHoldEnabled -bool true

Newer versions of macOS:

Accents off:

defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false

Accents back on:

defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool true

Accents do not play nice with single-key long press triggers in Keyboard Maestro.

-Chris

3 Likes

Hi @ccstone, thanks a lot, I disabled this a long time ago because I don't need it (and it is annoying). But that does not help here.

Single key short/long press actually doesn't work at all - unfortunately. Not for people who can write fast. The reason is clear: if one letter is typed on release and the next on pressed, it can't work.

The question is: Why does macos manage it with its "bubbles"? "a" is written on down (short press). If the key is held longer (long press), the "bubble" appears. This is perfect short/long press behavior, which apparently no other software manages :man_shrugging:

The forum has several examples of short press/long press macros that are not dependent upon press/release.

They are dependent upon an actual long-press.

Here is one example:

Ok, I didn't know that, thanks for pointing that out! After a quick look, I have no idea how to use that. Before I get into it. I'm looking for something that doesn't cause delays in writing with a single key trigger. Eg, short press "a" = "a", long press "a" = something else. Do you think this works?

Of course it works!  :sunglasses:

Here's a more germane example:

Short-Press - Long-Press Keyboard Shortcut Example v1.00.kmmacros (9.1 KB)
Keyboard Maestro Export

This method isn't perfect, because Keyboard Maestro is listening to the system and emulating key-presses and is not a driver-level utility. Even so – chances are pretty fair that it'll be good enough for your purposes.

If you need something more sophisticated the only thing I know of is Karabiner-Elements – it does run at the driver level.

-Chris

3 Likes

Unfortunately this is not true, dear Chris, the macro you suggested suffers from the same disease as all of its kind. The letters are typed when released, not when pressed.

This leads to the problem I explained in the post above. Example with "j". The macro does not type "jeep", but "ejep". The reason is obvious.

Karabiner Elements does exactly the same (mess). The only way would be to output the letters in the same order as they were typed. Like in a queue, who comes later, stands behind.

I know only one software, which "manages" both actions, short and long, when pressed, so that normal writing is possible. But this is a bug in the software, which I discovered by chance! :rofl: Setting up these actions is very laborious and it is a maintenance nightmare. That's why I'm still looking for other solutions.

I nevertheless thank you very much for your help. :pray: If you think of anything else, I am a grateful listener. :smiley:

Frank