Applescript to Map Esc to Caps Lock when tapped; C

2019-07-26 06:29发布

问题:

I am well aware of karabiner-elements which is still in development to enable this key mapping in macOS Sierra. However, at the current moment it doesn't work.

My thought is that if I map Caps Lock to Control in Preferences/Keyboard/Modifier Keys that gets me half way there. I have seen some interesting things people have done with AppleScript here. I am hoping there is a simple way to achieve this via AppleScript. Its also worth mentioning that karabiner-elements is capable of swapping Caps Lock and Escape (here are their examples).

Moreover, I tried to use Keyboard Maestro but my macro wouldn't recognize my Caps Lock key for my MacBook Pro 2015--I did set my Caps Lock to "No Action" in keyboard preferences, restarted, etc. Below is a screenshot of what it should look like in Keyboard Maestro for reference.

In short, I tried everything and hope there is a simple solution to achieve this via AppleScript. Thanks in advance.

回答1:

Perhaps you could try creating a custom key binding file, which works natively.

Also, here is a helpful tool you can use to edit the key bindings file.

Hopefully that helps.