Caps Lock LED never updates on a Bluetooth keyboard that declares two caps lock LED output elements (Karabiner writes to the wrong one)
Details
Summary
On a Bluetooth LE keyboard that declares more than one caps lock LED output element, Karabiner writes the caps lock LED to an element the keyboard's firmware does not act on, so the LED never updates. macOS's own caps lock handling writes to the other element on the same device, over the same BLE link, and there the LED works.
The same physical keyboard works correctly over USB, where it is enumerated as a different device.
To be precise about what is and is not happening:
- Karabiner is not failing to send. The write is issued, relayed and transmitted, with no ATT error.
- The keyboard is not failing to receive over Bluetooth.
- Karabiner is writing to the wrong one of two matching elements.
I believe this is the root cause of #2752, which described the same symptom on a Bluetooth keyboard and was closed as stale without a reply.
Environment
- Karabiner-Elements 16.3.0
- macOS 27.0.1 (26A434), Apple silicon
- Keyboard: Lofree Flow 2 (for Mac), firmware 0.2.8
- Bluetooth LE:
Flow2-100@Lofree, classIOHIDUserDevice, VID/PID both0x0 - USB:
Flow2@Lofree, VID0x388d/ PID0x0027(a separate entry in the Devices tab)
- Bluetooth LE:
Modify eventsenabled andManipulate caps lock LEDenabled for both entries
Symptom
With the keyboard connected over Bluetooth and grabbed by Karabiner, the caps lock LED never lights. Over USB, with the same settings, it lights correctly.
Nothing is logged. core_service.log contains zero update_caps_lock_led is failed warnings. Given the 3-second retry timer, a write that was failing at the point where the return value is checked would produce a steady stream of warnings, so the failure is happening somewhere that is not checked.
The device declares two caps lock LED output elements
Counting IORegistry Elements entries with UsagePage 8, grouped by node (Type 129 = kIOHIDElementTypeOutput):
Apple Internal Keyboard / Trackpad UsagePage8 5 all Output usages 1-5, one set CapsLock+Output: 1
Flow2-100@Lofree (Bluetooth LE) UsagePage8 10 all Output usages 1-5, TWO sets CapsLock+Output: 2
Karabiner DriverKit VirtualHIDKeyboard UsagePage8 4 Output 2 CapsLock+Output: 1The Lofree declares the standard five-LED set (NumLock / CapsLock / ScrollLock / Compose / Kana) twice, so there are two output reports and correspondingly two GATT Report characteristics.
The GATT characteristic handle differs depending on who writes
bluetoothd logs GATT writes at debug level by default, so this is observable without PacketLogger. Note that log is shadowed by a zsh builtin, so /usr/bin/log is required:
# Find the device UUID:
# /usr/bin/log show --last 5m --predicate 'process == "bluetoothd"' --style compact \
# | grep CBPowerSource | grep '<keyboard name>'
# ... then:
/usr/bin/log show --last 3m --predicate 'process == "bluetoothd"' --style compact \
| grep 'Writing value.*<device UUID>' \
| grep -oE 'handle 0x[0-9a-f]+' | sort | uniq -c| Karabiner grabs the device | GATT characteristic handle | LED |
|---|---|---|
| yes | 0x0031 |
does not light |
| no — macOS writes | 0x0029 |
lights |
| yes, restored | 0x0031 |
does not light |
Toggling ignore for that device flips the handle back and forth, reproducibly. Same device, same relay process, no ATT errors in either direction.
The write chain is intact in both cases:
Karabiner (IOKit element write)
-> IOHIDUserDevice
-> /usr/sbin/BTLEServer (XPC: CBMsgIdCharacteristicWriteValue)
-> GATT write with response -> keyboardKarabiner's writes land on a clean 3-second grid (the retry timer), with additional off-grid writes exactly when the caps lock state changes — so the "LED on" write is genuinely sent and genuinely transmitted. It simply goes to a characteristic the firmware ignores.
(Speculation, not verified: the two report characteristics may be the boot-protocol keyboard report and a second report map, with macOS writing the former and Karabiner the latter.)
Reproduction
- Connect over Bluetooth LE a keyboard that declares more than one caps lock LED output element.
- Enable
Modify eventsandManipulate caps lock LEDfor it. - Turn caps lock on. The LED stays off; nothing is logged.
- Set that device to ignored in the Devices tab. Turn caps lock on from that same keyboard. The LED now lights.
- Compare the GATT handles with the
log showcommand above.
Suggested fix
hid_keyboard_caps_lock_led_state_manager selects a caps lock LED output element when it is constructed. On a device that declares several matching elements, the one it selects may not be the one the firmware acts on. Writing to all matching elements, or preferring the one belonging to the boot-protocol keyboard report, would fix this.
Related
- #2752 — same symptom on a Bluetooth keyboard: works over USB, does not over Bluetooth,
Manipulate LEDenabled. Opened 2021-06, closed as stale 2026-02 with no maintainer reply. That reporter also noted the keyboard is enumerated as a different device over cable. - #4571 — the new
set_caps_lock_ledaction presumably goes through the same element selection, so it would inherit this bug on such devices.
Note on a separate, undocumented behavior found while investigating
Not a bug report, just a documentation note that may be worth adding: Karabiner sets the IOKit property CapsLockDelayOverride = 0 on each device it grabs, and restores it when the device is released. This is the implementation behind "Karabiner-Elements disables the caps lock delay without any action since v13.3.0" in the docs.
The consequence is not documented: on a keyboard whose firmware sends a real KC_CAPS and which the user relies on for input-source switching, setting the device to ignored makes the switch noticeably laggy again. That surprised me for a while, since nothing in the docs or the issue tracker mentions the property or that it is applied per grabbed device.
Source: pqrs-org/Karabiner-Elements