CAPS Lock on the Touch Bar?

Is it possible to use BTT to create a "caps lock" button in the touchbar?

Why?
I am a vim user stuck with Touch Bar Mac and want to map caps lock up to touchbar and then change "caps lock" key to esc for my sanity and speed of typing. I still use caps lock for long strings of all caps in my code, so I cannot just remap caps lock to esc without some way to touch something to enable caps lock.

Looks like using an AppleScript key code might not work, but it’s worth a shot: https://eastmanreference.com/complete-list-of-applescript-key-codes

Alternatively, synthesize an NSEvent with the caps lock modifier flag: https://developer.apple.com/documentation/appkit/nseventmodifierflags/nseventmodifierflagcapslock?language=objc

Example: https://github.com/andrewchidden/btt-services/tree/master/Sources/controlstrip-service

1 Like

Thank you! I'll give it a go.

I have the caplock key bound to escape as for my workflow I really need a physical escape key, so for the rare tiems I want to use capslock (actually hasn't happened yet haha) I have a btt button that does it.

It's really easy, make a btt touchbar button, then in the predefined action drop down menu, find 'toggle capslock' (under keyboard keys) and that's literally it. Shouldn't take more than 15 seconds to do.

Don't need to mess around with applescript at all.