Can I distinguish left/right Alt/Option key in macro trigger?

Can I distinguish left/right Alt/Option key in macro trigger?

I want a macro to only trigger using the right Alt/Option key + a letter (to mimic some rcmd functionality).

Unfortunately not. If you want to distinguish between left and right modifiers, you need an app like BetterTouchTool or Karabiner.

But there is a workaround with KM, with which you can use "Space" as a "modifier" (or any other key).

Space then has two functions.

(1) Space briefly tapped = Space

(2) Space pressed and held, opens a palette that shows your macros. (I assume you are familiar with palettes).

So, space + letter, has the same function as right ⌘ + letter. It works fine if you don't type too fast. Otherwise, you'll get letter twists.

Here is the macro that @Nige_S was kind enough to provide. Hope this helps.

Palettes and Spaces v2.kmmacros (3.9 KB)

Ah, and of course there is also the great multipress macro from @noisneil

Hotkey : USB Key Original.kmmacros (82.7 KB)

This does the following.

⌘+a, does something
⌘+a+a, does something else
⌘+a (long pressed), does something else again


This macro will detect which βŒ₯ key is pressed and set a global variable:

βŒ₯ Detect L-R.kmmacros (22 KB)

Macro screenshot

This means you can now do different things with the same hotkey depending on the state of that global variable. Here's an example, using βŒ₯L. You'll see a notification saying "LEFT" or "RIGHT" depending on which βŒ₯ key is pressed down as part of the hotkey trigger.

L-R βŒ₯ Triggers.kmmacros (21 KB)

Macro screenshot


Oh, is that a brand new macro of yours?

Just made it for @rob. I don't really use many hotkey triggers, so not something I've ever needed myself.

1 Like

After the first test, this seems to work well. :grinning: Very many people here have asked for this feature. Everyone's answer was always, KM can't do that. And now you did it in two minutes? :joy:

I must confess, in the meantime I got used to the multipress macros very well. I think I'll stick with it. But it's good to know that this option is now available.

1 Like

Just for the record, if you'd done a thorough search you'd have seen me say this in January:

" For a very long time I've been using the βŒ₯ key to trigger macros. Here's an example showing the left and right Option keys double-tapped being used as a trigger"

in this post: Double tab cmd/opt/shift/control as hotkeys - #4 by tiffle

Of course, I added the caveat that I didn't know if the approach worked without an external keyboard, but for those who do use one now you know!

1 Like

I suppose what @Frankb might be alluding to is the idea that you can use the left/right modifiers as part of a hotkey trigger key combination, rather than as isolated triggers themselves. It's pretty basic logic, but in case it hasn't been overtly stated elsewhere, I've added it to the macro library.

1 Like

OK, I didn't see that, sorry, then everyone except you said KM can't do it. :grinning:

If I think about it correctly, this is also the solution for Hyperkey with KM (without Karabiner).

You change in macos Caps Lock to control. Then Caps Lock is the physical right control key, which is missing on most keyboards.

Then right control can perform a different action than left control? Is that correct?

Yes, but also what @tiffle did can be very, very useful. I do this with BTT.

I don't know about that since I have an external keyboard with 2 control keys. You could expand all our knowledge by trying it out yourself if you have that kind of keyboard and reporting back here perhaps!

It's nice to see @noisneil's solution go into the Library!

@noisneil I am probably doing something wrong. When using your macro with βŒ₯+L, the text shows "RIGHT" with both modifiers. I didn't see this before when I tried this just briefly. :thinking:

You will probably need to recapture the USB Device Key triggers in the detection macro. You mentioned you have a right-side βŒƒ key; I don't have that, so it seems we may be using different input devices. Also, make sure none of your other keyboard-related apps are interfering (Karabiner/BTT etc).

Open up the variable inspector (KM prefs) and you should see the stored value of OptionKeyLR change from "Left" to "Right" when you tap each of your βŒ₯ keys.

That would be awesome for me as well, for a different use case (replace Hyperkey, which is buggy for me).

Unfortunately, it is still detected as a Caps Lock key after changing the modifier in macOS settings.

(Additionally the LED still blinks then, which I hate - and why I use the HyperKey App, despite an annoying bug)

Really? is that how you did it?

@noisneil I think BTT is preventing your macro from working properly. I would have to delete many things because disable is not enough. I do not want to do that.

But if it works for you, I'm sure it works for everyone else. Congratulations then, you probably just solved the hyperkey problem.

Yes, that’s how I did it (and which does not work for me).

Mh, did you disable your hyperkey app and maybe restart your mac?

Disabled Hyperkey, but did not restart my Mac.

I was really curious to know if @noisneil's macro also works with left control and right control (caps lock).

And YES, it works!

Left/right control + (same) letter are recognized as different shortcuts, perform different actions and can be used as hyperkey replacement.

Although "right control" is recognized by KM as "Caps Lock", the key behaves like the physical "right control" key.