Setting up custom, app-specific keyboard shortcuts

I would like to customise the keyboard shortcuts on apps that I use frequently, two of these being Figma and Evernote. Mac OS Sonoma offers a way to do it natively, under system settings (keyboard > shortcuts > apps shortcuts), and it's a very nice feature, except it doesn't always work as it should—app can still interpret my shortcuts on the basis of the status they are in.

I am trying to do this in Keyboard Maestro, and see if it works. I just created a new macro group and enabled it on a selected app only. In order to do that, I had to select the option "available when these applications are running", as the option "available in these applications" did not work. Within that group, I created macros where a trigger is define (the default kb shortcut I want to modify), and as an action, I am adding the keystroke that I'd like to get executed.
This works very nicely, the only issue is that if the same shortcut is used on tow or more apps, the instead of executing the macro, KM shows a dialogue, asking me to choose the macro I want to run (which defeats the whole purpose…). The problem is that both apps are running, not just the one in focus, but apparently there is no way to only execute a macro in the app that is in focus (as mentioned above, the option "available in these applications" does not work with Figma and Evernote). I also couldn't find an "app in focus" condition that I could set as a trigger, sand "available when a focused window exists" does not what I need. Any idea to bypass this problem?

I only had a few minutes to read your question, but I want to chime in with my first thought.

Yes, that's how that works, but you can fix that by having a single macro, instead of two, and branch to the appropriate code for the appropriate app if your preferred app is "at the front" like this: (in my case, News and Messages are sample apps)

1 Like

Start your troubleshooting here, because that option works for 99% of people in 99% of apps.

Start simple with an hot key triggered macro, triggered by A, that just puts up a dialog. Put it into a Sigma-only Group. Switch between Sigma and the Finder, testing your A trigger, to see if the macro fires as expected.

Here you go:

Figma Beep Test.kmmacros (2.7 KB)

Once you've got that working you'll know your triggering setup is right.

Then it's on to the next set of problems, which will arise because Figma (and, I believe, Evernote) aren't "proper" Mac apps but Electron ones -- web apps with their own Chromium wrapper. That can make some normally easy actions, such as selecting menu items... interesting.

2 Likes

I am trying to do this in Keyboard Maestro, and see if it works. I just created a new macro group and enabled it on a selected app only. In order to do that, I had to select the option "available when these applications are running", as the option "available in these applications" did not work.

Can someone expand a little more on why this did not work..
I do not have Evernote nor Figma to understand the reasons given above.

Is this a "KM" problem?

In my testing with freshly-installed Figma it did work as expected, so I suspect something's not been set quite right.

@Airy Thanks this is an interesting approach, I did in fact try to do something like this but could not find a way to do that. I wonder if we are on the same version of KM, though. I am running v. 11.0.3 and the UI I see shows a "Triggered by any of the following" checkbox instead of the graph brackets that I see in your version, and I can't find any "is at the front" condition. The options available in the dropdown associated to the condition "This application" are displayed in the attached screenshot. I am going to reach out to
to see if they can help with this.

@Nige_S Yes exactly, and that probably explains why these apps don't support the native mac OS functionality to modify app shortcuts. I didn't consider that but it's probably the reason why I had to resort to KM to solve this... Great hint from you, thanks!

You are looking at your macro's Triggers -- @Airy was showing you the "this app is frontmost" condition in an "If Then Else" action.

Ignore that for now -- concentrate on getting your Figma macros to work only in Figma. Because "available in these applications" does work with Figma -- fixing that problem makes the rest redundant.

1 Like

Thanks @Nige_S that was very helpful, the "available in these applications" does work, indeed. Not sure why it wasn't, when I was testing it, maybe something else in the macro was not right. I've also tested the option "available when these applications are running" option, with the available when a focused window exists" sub-categry selected, but that still returns the dialog that I was describing in my original post. So the solution you are suggesting definitely works.
Good to know that conditions can be set: as a new user, I was not aware of that! I think the choice of placing conditions under actions is not a very good one, it makes them hardly noticeable.

It has to go there -- it's the condition for that "If" action.

Reading @Airy's screen shot out loud it is, quite literally:

"When we get to this point in the macro's execution, if the application News is at the front then..." followed by "And now we are here in the execution, if the application Messages is at the front then..."

These "mid-macro" actions and conditions are quite separate from a Group's activation conditions.

1 Like

Not sure I agree with that, I think they should be separate, e.g. in the interactions builder in Axure RP, conditions have a bespoke button so one can add them. In Figma they are also mixed with actions, but there's only very few actions to choose from, and one single condition (if… else..), then in that case it makes sense. In KM, there are lots of actions and several conditions, and they are all mixed together despite having a rather different nature (regardless of the fact that they can be all added in the same timeline-based sequence). A UI like this is quite complex to build, so I don't blame them but I find the windows management and interaction not very exciting, overall.

By the way I was rejoicing over victory too early… I've just reactivated another Figma-targeted macro that works perfectly with the "available when these applications are running" option, but for some reason it does not run with the "available in these applications" option, not even with a focused window. I was induced to think that it works because I was testing a macro with a shortcut that produces the same result if run natively. So the problem in principle still exists, although for the time being I am fine — I just used the option "available when these applications are running" for Figma, and the "available in these applications" option for Evernote. Weird, but it works. Would be great to have someone from support could chime in and clarify. I suspect the reason you've given before may be the culprit: these are not proper Mac OS apps and their behaviour may be unpredictable.

I don't understand. An "If" action must have a condition -- that's the whole point of it! -- so where should it go if not there?

@Nige_S I think this must be a bug in KM. I tried to import the macro you've provided above, it works insofar it sits in the folder you've created. As soon as I copy/paste in my macro folder, which has exactly the same "enable macro group" setting as yours, it stops working.

App-specific: Figma Macros.kmmacros (6.4 KB)

"If" is a condition, not an action. The actions gets added to the condition, but the condition is something separate, that adds logic to an otherwise linear sequence. See screenshot attached, from Axure RP.

Make sure Figma is running. Go to KM and remove Figma from the Group's availability list, then add it again. That's exactly what I've just had to do to make your Macro Group behave as you want it to.

When talking about KM we should use KM terminology, yes? So "If Then Else" is an action (or Action) which allows a choice between two execution routes, depending on whether conditions are or are not met.

The Wiki Page for the Action we are talking about.

Thanks for the suggestion, appreciated. You will agree that seems to be a bug, though.

I was not using KM terminology, just common sense terminology. My mental model as a user is that "if" is a condition, not an action. The conceptual model exposed in the UI (if as an action ) does not match my mental model. I am not claiming that my model is the predominant one but I strongly suspect that for someone new to KM, those conditions are too difficult to notice, and in fact I was not aware of them. Once you are aware that they exist, it's not so much of a big deal, although I still think they could be handled differently.

No. It might be a side effect of macOS application registration and Electron apps, though. If it happens again (maybe a Figma update, or a change because of translocation [a good summary here]), try changing the "Match by..." option at the very bottom of that application picker drop-down.

While I strongly suspect that, for most people, "If" means "We're about to make a choice, based on...". Then there's the condition(s). Then there's the conclusion(s).

If -- here comes a choice!
   it is raining -- the condition to evaluate
then -- what to do when the condition evaluate to 'true'
   I will take an umbrella

I also suspect that most people don't think that deeply, and end up getting wet :wink: We're lucky because, when confused and at risk of a damp head, we can turn to the KM manual, the Wiki pages (right-click on any action and select "Help"), and this Forum for help.

I think that we are dragging this conversation for longer than it needs to. There is a reason why in many — if not most — rules builder UIs, conditions are separate from actions: they are two different things. Here you can find several examples: Rule Builder screenshot collection.
Another example that I can think of is the Shortcuts app on iOS, where there's two clearly labeled, separate sections: 'when' (condition) and 'do' (list of actions).
To answer your last point: while I appreciate there's people like you who are willing to help, a good UI is one that is self-explanatory and does not require people to look at a forum or user manual, but one where people can rely on contextual cues. It is clearly not the case here.

Here's equivalent KM and Shortcuts blocks, matching parts outlined in the same colours:

The KM version takes up more space, partly because there are generally more options and partly because I didn't think to "Show More" on the Shortcut actions, but is there any actual difference in the way the two are structured?

Both are a single "If" action -- the main difference is that Shortcuts more clearly delineates the sections within the action. I'll agree that this is the more "modern" way of presenting things, but it'll quickly start to grind your gears once you start nesting "If"s and creating longer, more complicated, conclusions -- at that point KM's starker interface, ability to group and rename actions, and close things down with the disclosure triangles really comes into its own.

No-/low-code tools all do things in their own, different, ways and all but the few-featured have to balance ease of use with making functionality available. KM obviously isn't perfect, but it does do a good job of presenting an awful lot of functionality in a reasonably useful way.

Good post. I agree. Sometimes KM's verboseness can be a little too much, but it does the job well and I wouldn't trade it for a million dollars.