Is There a Way to Remap Modifier Keys in a Specific Application?

In Things 3, the user can create tags and assign them hotkeys. E.g. I have a tag called "urgent" with the hotkey U. To assign the tag to a selected item, I type Ctrl-U.

I don't like the Control key as a modifier for tag assignments. I want to use Command-Option instead. Things won't let me do this, and nor will the Keyboard Preference Pane (because individual tags and hotkeys are set by the user and don't appear in the application menus).

So I thought I might create a KM macro that would be triggered whenever Command, Option, and a non-modifier key are pressed, and that would respond by simulating Control with the same non-modifier key.

Is this possible?

If you don't have too many tags you can do this:

You have to make a macro for each tag hotkey. (You can duplicate macros with ⌘D.)

Make sure to put the macros into a macro group that is only active in Things.

Currently I don't see a way to generally translate any pressed ⌥⌘ combo to a Control combo. We would need a complex trigger consisting of pressed modifier + typed string regex. But maybe someone else has an idea.

Karabiner Elements can probably remap the modifiers (or Karabiner for a pre-Sierra OS). But I don't know if you can limit this to a specific application. It would also interfere with Things’ other ⌥⌘ shortcuts, like ⌥⌘N, ⌥⌘W, ⌥⌘⇡ etc.

Thanks. Yes, I’ve done that for a few tags but I keep adding new tags and
getting annoyed that they don’t work like my other tags.

Remap the Caps-Lock key to Control and you’ll love Control-key shortcuts :wink:

(System Preferences > Keyboard > Modifier Keys)

One approach is to use a Typed String trigger (KM Wiki), where the last character of the string indicates the tag to be assigned. Something like this:
;t\w
using the regular expression match.
The \w will match any alphanumeric character plus underscore.

Then you do a Switch or Case action (KM Wiki) based on the last character of the %TriggerValue% to select the tag to be assigned, using a Things menu item.

I don’t have Things 3 app, so I can’t test.

1 Like

Tom, this sounds interesting. If I do that, is there an alternate way to turn on Caps-Lock?

Remap the Control key to Caps Lock.

Or, if you want to keep the original Control key for those ⌃⌥⌘-combos, use BetterTouchTool which allows you to assign a tap on any key (e.g. the Shift or Option key) to toggle Caps Lock:

Karabiner (Elements) can probably do the same.

I believe Karabiner Elements can map Caps Lock to Control (or better yet Hyper - Command,Shift,Option,Control, great for macro triggers!), and can also do Caps Lock if it is simply tapped.

So tapped toggles caps lock, and Press and Hold give Hyper (or Control) modifier.

1 Like

You can do this as well in System Preferences.

Yes, to a single modifier (eg Control), but not retain the ability to toggle Caps Lock (as far as I am aware?) and not for Hyper (multiple modifiers).

But you can just map Caps Lock to Control certainly.

Thanks for this suggestion. If I’m understand it correctly, I’d have to add a new Switch or Case action every time I added a tag—which rather defeats the purpose, since I can just add a new KM macro for each one. (I guess adding the action has less overhead than creating an entire macro, though; on the other hand I usually prefer modifier-key shortcuts to string triggers for things like this.)

Actually, not a new Switch Action, just another case within the existing Switch.
It's very simple and fast. Just click on the + button to add a new case.
This is much, much less work than creating a new Macro.

See this macro for a downloadable example:
MACRO: @Word Old Win Shortcuts @Example

1 Like

Ah, I see what you mean. I didn’t understand how the Switch action worked.
Much better this way! Thanks.

Sorry (maybe) for reviving this.
I have a few applications like Inkscape that were originally developed for Linux or Windows. They do not ever use the command key, but they do use the control key ctrl.
It would be useful to have:

"When application X-11 is active"
"switchmodifierkey CTRL to Command"

Obviously I could do this by going to the system preferences and switching, but that is a nuisance.
I could also do it by AppleScript:

-- Toggle between CTRL and COMMAND for the command key on my second keyboard

tell application "System Preferences"
	activate
	set current pane to pane id "com.apple.preference.keyboard"
	delay 0.5
end tell
tell application "System Events"
	tell process "System Preferences"
		click button "Modifier Keys…" of tab group 1 of window "Keyboard"
		delay 0.1
		tell sheet 1 of window "Keyboard"
			click pop up button "Select keyboard:"
			click menu item "iMate, USB To ADB Adaptor" of menu 1 of pop up button "Select keyboard:"
			delay 0.1
			click pop up button "Command (⌘) Key:"
			if value of pop up button "Command (⌘) Key:" = "⌘ Command" then
				click menu item 2 of menu 1 of pop up button "Command (⌘) Key:"
			else
				click menu item "⌘ Command" of menu 1 of pop up button "Command (⌘) Key:"
			end if
			delay 0.1
			click button "OK"
		end tell
	end tell
end tell

While that does work, it is horribly slow, it activates the System Preferences, needs delays to work properly, and is just a kluge. I would not want to hang that applescript from a macro.
Perhaps there is a command-line setting to do it (I did not find one).

In any case, it does not work as desired because X-11 produces an activation message each time I click in an Inkscape window! (OK, so the real answer is to tell the Inkscape guys to make a native macOS application, but that's asking for the Moon).

Any thoughts welcome…

1 Like

I found this thread because I'm looking to do the same thing @RobertCailliau is doing. I use a remote desktop tool to connect to a Windows computer from my Mac. Out of muscle memory I keep hitting the CMD key for shortcuts like Select All, Copy, Paste, etc., which opens the Windows menu or other things on Windows. I'm trying to find a way to remap the Command key to CTRL (and so on) only for use within the remote desktop sharing application.

I thought I could do it with KM, but KM doesn't recognize just a modifier key (e.g. CMD) as a valid trigger.

Any suggestions 2.5 years after Robert's post?

@RobertCailliau @iampariah

I was looking for a solution for this also. Right now it seems KM is not made to remap keys.

However, Karabiner has a ready-made modification rule just for this purpose.

image

2 Likes

I have similar issues with vmware running windows. I simply use “cmd + c” as a trigger for a macro that will simulate “ctrl + c”. I created other macros that do similar things when I intended to hit “ctrl” for windows but instead hit “cmd”.
Of course, all these macros are put in a group that is active only when vmware is the front app.

In this way, we don’t need to remap the key in Kakabiner-Elements.

Another option, instead of getting a low level software utility, is to buy a keyboard that's fully reprogrammable. Here's a description of the Gateway Anyway keyboard's abilities:

The AnyKey keyboard is extensively programmable. This takes two forms: Remapping, and macro programming. The only keys on the AnyKey that cannot be programmed in at least some way are those used to control the programming itself – Program Macro, Suspend Macro, Repeat Rate, and Remap. Any other key on the keyboard including letters, numbers, arrow keys, and even special keys like modifiers such as Shift, Alt, Ctrl, Enter, and the Space Bar can be programmed.

The AnyKey is out of production now, but it's still available on eBay for $100 (!) plus $70 shipping (!!). I found other models that are (or were) available: AZiO Levetron Mech5, CM Storm Trigger, Deck Hassium, Gateway AnyKey, Perrix PX-3000, Tesoro Lobera.

I use Parallels rather then VMWare. In Parallels the keys can be mapped to be Mac-like i.e. Control to Command. And I think the same can be done in VMware:

https://docs.vmware.com/en/VMware-Fusion/12/com.vmware.fusion.using.doc/GUID-5E971E88-DEB1-4A37-8245-401732CBACFA.html

@martin I tried this but it doesn't work with VNC Viewer. So I had to use Karabiner.