I tried to follow: https://community.folivora.ai/t/26873, or set up in Key Sequences, but it doesn't work until I am currently switching to Raycast by setting as below:
Raycast works well, but sometimes is unstable, for example, I tried to detect Hyper key in BTT what key is pressed: sometimes is F20, but restart raycast will be changed to cmd+shift+ctrl+opt.
Anyway, I'd like to use BTT as my first choice for all of keyboard shortcuts management, is there any plan to look into it and improve it?
I have added a "unused" long hold option in 6.968 (uploading now), so now you can assign the "Toggle Caps Lock On/Off" action to "Actions Executed On (Unused) Hyperkey Release After Long Hold (new)"
If I press CAPS key once, sometimes it will trigger to take action twice at almost same time.In BTT log it says:
enable Hyper - 0
performing SKA
triggering action Act as Hyper Key - 9D065EE3-BB39-428C-B8EF-9DA4891A518E
triggering action Act as Hyper Key - 9D065EE3-BB39-428C-B8EF-9DA4891A518E
after enabling hyperkey modifier mask 393216
...
I tried to:
set caps lock key with "no action" in keyboard setting of macOS, it doesn't work.
disable my hyper key trigger in BTT to check in BTT console log, if press caps lock key there is no log appeared.
I found it's the cmd+space problem, because I create a new trigger to execute cmd+space switching IME, same problem. So I use AI to build a executable bin file in place of cmd+space, seems to be OK now:
mkdir -p ~/.local/bin && cat << 'EOF' > /tmp/toggle_ime.swift
import Carbon
let current = TISCopyCurrentKeyboardInputSource().takeRetainedValue()
let currentID = Unmanaged<CFString>.fromOpaque(TISGetInputSourceProperty(current, kTISPropertyInputSourceID)).takeUnretainedValue() as String
let targetID = (currentID == "com.apple.keylayout.ABC") ? "im.rime.inputmethod.Squirrel.Hans" : "com.apple.keylayout.ABC"
let filter = [kTISPropertyInputSourceID: targetID] as CFDictionary
if let sources = TISCreateInputSourceList(filter, true)?.takeRetainedValue() as? [TISInputSource],
let target = sources.first {
TISSelectInputSource(target)
}
EOF
swiftc -O /tmp/toggle_ime.swift -o ~/.local/bin/toggle-ime && rm /tmp/toggle_ime.swift
This is AI replied:
The issue stems from a combination of macOS input source switching behavior and BTT's Hyper Key detection:
1. **System Shortcut Race Condition & Bounce**: When macOS triggers input source switching via standard shortcuts (like `Cmd + Space` or internal system actions bound to Caps Lock), the system handles input source updates asynchronously. If a shortcut event is processed while the previous state transition is still settling, or if the virtual event sequence causes a micro-delay/bounce, macOS's input method manager treats it as a second toggle command, instantly flipping the input method back.
2. **BTT Hyper Key Multi-Trigger Artifact**: In BTT's "Act as Hyper Key" mode, depending on the rapid release/tap window or hardware key bounce, BTT can occasionally fire the mapped action twice within the exact same millisecond window. When the action sends a system shortcut that toggles states, firing it twice consecutively forces an unintended double-toggle (e.g., switches to ABC and immediately back to the previous input method).
To avoid the system-level toggle race conditions completely, users have to bypass simulated shortcut triggers and instead execute a compiled binary directly invoking Carbon APIs (`TISSelectInputSource`), combined with a software debounce guard.