Key-up trigger does not activate if user clicks app in dock before releasing final key

Describe the bug

Create a keyboard trigger:

  • Shortcut: cmd+a (or any other 2-or-more-key shortcut)
  • Condition: Trigger on Key Up
  • Enable HUD Overlay and set Title so we can see whether the trigger activates

Now try to activate the trigger:

  • Hold cmd+a
  • Let go of cmd
  • Click on an app in the OS dock
  • Let go of a
  • See that the HUD overlay never appeared

Confirm that the trigger works otherwise:

  • Hold cmd+a
  • Let go of cmd
  • Let go of a
  • See that the HUD overlay appears

Device information:

  • Type of Mac: MacBook Pro 16-inch 2019
  • macOS version: Big Sur 11.4
  • BetterTouchTool version: Latest stable (not sure how to revert from alpha to check number) and alpha version 3.571

For context, my specific use case is:

In order to keep the dock hidden almost 100% of the time but still be able to access it easily, I want to be able to hold cmd+escape to temporarily show the dock (via AppleScript) and then hide the dock again (via AppleScript) when I release cmd+escape.

The dock also stays up as long as I have my mouse over it, even once I've set it to hide again, which is exactly what I want. But sometimes I find myself clicking before I let go of escape, in which case the dock stays open indefinitely because my second trigger (the key-up one) never activates.

This bug occurs in the simple case I described in the repro steps, whether I'm running scripts or just showing a HUD overlay, but I'll include my scripts below anyway.

My specific setup:

Run this once: defaults write com.apple.dock autohide-delay -float 31536000 && killall Dock

Key-down trigger:

tell application "System Events"
	# hack to ensure we can still cmd+esc out of the cmd+tab UI
	tell process "Dock"
		if exists list 2 then
			key code 53
			return
		end if
	end tell
	
	# show the dock
	tell dock preferences
		set autohide to no
	end tell
end tell

Key-up trigger:

tell application "System Events"
	tell dock preferences
		set autohide to yes
	end tell
end tell

I found a better solution for my use case, which bypasses this bug: Just bind cmd+escape to Mission Control in the native keyboard shortcuts. It accomplishes basically the same goal, and it even looks cooler! :grinning_face_with_smiling_eyes: