Toggle Caps Lock On/Off

There is a small bug with the assigned action "Toggle Caps Lock On/Off".

BUG STEP BY STEP:

  1. I set the shortcut "CMD+L" to launch the action "Toggle Caps Lock On/Off".

  2. I hit "CMD+L" to toggle the caps lock on/off, and I leave the caps lock ON (same behaviour if I hit the shortcut once or several times)

  3. with the caps lock ON, I hit the Caps Lock key directly, and I leave the caps lock OFF (same behaviour if I hit the key once or several times)

  4. I hit the shortcut "CMD+L" once. It should set the Caps Lock ON, but the shortcut doesn't do nothing. The led of the key is off and computer writes in lower cases.

  5. I hit again "CMD+L" and everything works fine again. The shortcut toggles on/off caps lock correctly.

So, the bug is the behaviour described in step 4.

In other words:If caps lock are toggled with BTT actions to ON, and after that, the caps lock are toggled with the caps lock key to OFF, then BTT will be not able to toggle caps lock to ON on the first attempt.

I have tried several shortcuts with different modifiers. I also tried using named triggers with the assigned action, and direclty the assigned action. No success, the bug is always the same.

I am not using the Hyper Key functionality.

Macos Mojave 10.14.6
BTT 3.579
Macbook Pro retina 15-inch, mid 2015

Dear @Andreas_Hegenberg

This bug is still existing in version 3.701

Hi @Andreas_Hegenberg

Sorry to disturb you again, but this bug is still occuring in my laptop after downloading version 3,729

I would appreciate if you could fix it in next release.

Thanks
Pep

I haven't attempted to reproduce this specific issue. But I'm having a bad time using the caps locks toggle in the latest version. I wish I had more control over the state of caps locks. Much like how there are specific actions for "fn key up" and "fn key down", I would like to be able set the specific state of caps locks as on or off. There's no easy way to do that with applescript or objc, afaik.

Isn't that exactly what the caps lock key or the predefined action does?

No, not in my testing. The predefined action "Toggle Caps Lock On/On" only toggles the state of the Caps Locks key. It does not specifically turn on Caps Lock, nor does it specifically turn off Caps Lock.

On a related note, I was able to use a modified version (see below) of the AppleScript provided by user Digital Trauma on stakeoverflow to detect when the Caps Locks key is pressed. However afaik AppleScript is not capable of changing the state of Caps Lock.

use framework "Cocoa"
use scripting additions

to isModifierPressed(modifier)
	((current application's NSEvent's modifierFlags()) / modifier as integer) mod 2 is equal to 1
end isModifierPressed

repeat until isModifierPressed(current application's NSEventModifierFlagCapsLock)
	delay 0.25 -- sad poll/wait loop :(
end repeat
display dialog "CAPS LOCKS was pressed"

# This snippet is based on code original shared here: https://stackoverflow.com/a/66266487