4
votes

My question is referring to the System Preferences setting that enables you to remap Caps Lock to e.g. Ctrl key.

^ Is it possible to affect this setting programmatically?

Primarily I'd be interested achieving this via defaults or some shell trick; secondarily via AppleScript (yuck).

I know I can probably achieve this by using 3rd party tools, such as KeyRemap4MacBook, but that's a last resort. But I'd rather prefer a non-3rd party solution, if possible.

My use case:

Using Keyboard Maestro and its nice macro triggers, I'm looking to automatically remap Caps Lock -> Ctrl in apps like MacVim, and toggle it back to normal Caps Lock when leaving the affected apps.

1
ever found a solution to this?cheesus

1 Answers

0
votes

You can toggle this using AppleScript. It'll be a simple automation technique, that will basically do the same toggle in System Preferences for you automatically.

You can add the created AppleScript toggle to the MacVim Scripts Toolbar icon. That way, while inside the app you can toggle it, and put it off while leaving.

Is this what you're looking for ? If you still need this I'll design the AppleScript for you and post it in here in a bit.