Temporarily disable modifier keys?

Here's my situation: I have macros triggered by Command-1 thru Command-9 keyboard shortcuts. The macros click a specific GUI element in the target application. The target application is coded so that the resulting action is different when the GUI element is clicked with or without the Command key being held down.

I want the element clicked without the Command key. However, if when typing the keyboard shortcut, I leave the Command key down for a millisecond too long, the target application sees this a having had the click occur with the Command key down, resulting in the wrong action.

I'm thinking that if there's a way to disable the command key at the start of the macro and re-enable it when the macro is complete, perhaps adding a brief pause beforehand, that this might solve the problem.

Anybody know a way to do this? Other suggestions?

Thanks!

Add a Pause Until action with the Modifiers condition set to all modifiers released.

A similar thing can happen when you use a hot key to launch an application and it detects the modifiers on startup and behaves differently, so this technique of pausing until you release all modifiers before actually performing the task of the macro can be generally applicable.

1 Like

Great, thanks! I'll try that. So obvious, not sure why I didn't think of it myself. :slight_smile:

UPDATE: Seems to be working. At first I put the "wait until" step at the top of the macro and that didn't work consistently. After I moved it to right before the "click" step, it seems solid now.

A Mac keyboard has four modifier keys; Control, Option, Command, and Shift. These keys are used to [execute shortcuts on the OS level], as well as in apps. If you have a different keyboard set up, one where one or more modifier keys are useless or a problem, you can disable or remap them with some exceptions. You can disable modifier keys on macOS as well as redtube.vin the Caps and Fn keys.

Disable modifier keys

You can disable modifier keys on macOS from the System Preferences. Open the app and go to the Keyboard preferences. Click the ‘Modifier Keys…’ button.

A new panel will open. This will list all the modifier keys that you can remap and/or disable. This panel lets you remap the modifier keys but only to the extent that you can interchange them e.g., you can have the Command key function as the Control key, and vice versa.

Since our focus is on disabling modifier keys, click the dropdown arrow next to the key that you want to disable and select ‘No Action’ from the menu.

To change what a key does, you can select one of the other modifier keys allowing you to use one key as the other. This will effect keys that are in pairs e.g., if you have two Option keys on your keyboard, and you disable them or remap them to the Command key, both will be disabled or remapped. The change takes effect right away.

There is no option to map these keys outside of the given options. That’s not to say it’s impossible, you just can’t do it with the System Preferences app. There are third-party apps that allow you to remap any and all keys on macOS. A free app that lets you do this is called Karabiner. The app is a bit complicated but it’s one of the most recommended apps for remapping keys on macOS.

If you have a broken modifier key on your keyboard, this is good way to work with it until you can have it fixed or replaced. When you disable a key, it stops working completely. It’s not just disabled as a modifier key i.e., it will no longer be recognized as a modifier key when you execute a shortcut but the key press will still register. Instead, it will appear as though the key simply doesn’t exist (or is broken). You can change the keys back whenever you want, and if you want to reset them all at once, click the Restore Defaults button.

Not sure if this reply was intended for me, but I was aware of all of that, including Karabiner. It's a great detailed explanation though.

However, it doesn't help in my case because I still need/want to use the regular Command key as intended. Just not have it register while the click shortcut is executing.

But @peternlewis's suggestion (as I noted above) is seems to have solved my issue.

No reply...?