Touch ID Steals Your Input Source: A macOS Debugging Story
A few months ago I started noticing that my input source would randomly switch to ABC. No shortcut pressed, no window focused, no deliberate action — just suddenly, mid-sentence, Rime was gone and I was typing raw ASCII.
The usual forum answers came up immediately: disable Caps Lock switching in System Settings, turn off "Automatically switch to a document's input source." I'd already done both. The problem kept happening.
The frustrating part wasn't the inconvenience. It was that the switching had no obvious pattern. Sometimes it happened five times in an afternoon. Sometimes it was fine for two days. Without a consistent trigger, you can't form a hypothesis.
So I built one monitor at a time until I found the answer.
Layer 1: Karabiner Logs
I use Karabiner-Elements for key remapping. It was the natural first suspect.
I pulled ~/.local/share/karabiner/log/core_service.log and grepped for caps_lock events:
Found something immediately. There were bursts of caps_lock events originating from a "virtual keyboard" — not my physical keyboard, but Karabiner's own virtual HID device that it creates to apply remapping rules. macOS has a built-in feature to switch input sources on Caps Lock press. The virtual device was triggering it.
I confirmed the device with hidutil list, identified its vendor/product IDs, and disabled the LED manipulation in Karabiner's config by setting manipulate_caps_lock_led to false.
That reduced the frequency noticeably. But the random, unexplained switches were still happening. So Karabiner was a partial contributor at most — not the root cause.
Layer 2: Shell Polling Monitor
To make progress I needed timestamps. I needed to know exactly when the switches were happening and what the machine was doing at that moment.
I wrote a shell script that polled every 0.5 seconds, logging the current input source and frontmost application whenever either changed:
After a few days of data, the switches were confirmed to be random — no single application consistently present. But 0.5-second resolution wasn't precise enough to correlate events to specific user actions, and osascript was too slow to catch brief system process transitions. I needed something event-driven.
Layer 3: Swift CGEvent Monitor for Caps Lock
Before moving to event-driven monitoring entirely, I wanted to rule out one remaining theory: that something was physically or programmatically triggering Caps Lock at the system event level.
I wrote a small Swift binary using CGEventTap to intercept all flagsChanged events and log any Caps Lock state transitions:
Output went to ~/.local/log/capslock-state.log. I ran this alongside the polling script and correlated the timestamps.
Result: during every unexplained input source switch, the caps_lock log was silent. No Caps Lock events at all. Caps Lock as a mechanism was eliminated entirely.
Layer 4: CGEventTap + DistributedNotificationCenter
At this point I knew I needed to capture input source changes at the TIS level, with millisecond precision, and simultaneously record which application was frontmost at the exact moment of the switch.
macOS broadcasts a kTISNotifySelectedKeyboardInputSourceChanged notification through DistributedNotificationCenter whenever the active input source changes. This is the authoritative signal — it fires at the TIS layer before any app-level handling occurs.
I combined this with NSWorkspace.didActivateApplicationNotification in a Swift app that ran continuously in the background:
Everything went to ~/.local/log/input-tap.log, timestamped to the millisecond.
The Smoking Gun
After running the full stack for a few days, I searched the input-tap log for every switch to ABC that I hadn't deliberately triggered:
Every single unexplained switch: frontmost application was loginwindow, coreautha, or SecurityAgent.
Not sometimes. Every time. No exceptions across dozens of events.
loginwindow is the system process that handles the lock screen and login window. coreautha is the Core Authentication daemon — the process that handles Touch ID prompts, Apple Watch unlock, and other authentication requests. SecurityAgent handles privilege escalation dialogs.
I cross-referenced the timestamps against my behavior. Every one of them mapped to a moment when the system presented a password or authentication prompt — Touch ID, unlocking a Keychain item, approving a software installation, a sudo prompt, even 1Password's password entry field.
Root Cause
The full causal chain:
- The system presents a password or authentication dialog (Touch ID, privilege escalation, 1Password, etc.)
- macOS brings an auth-related process to the foreground, or activates Secure Input mode within the current app
- macOS switches the TIS input source to ABC — password fields require ASCII input; the system enforces this
- Authentication completes; the original application regains focus
- macOS does not restore the previous input source
Step 3 is intentional behavior — a sensible safety measure. Step 5 is the oversight. The system bothered to switch away but never bothered to switch back.
It's not just Touch ID — any system-level password prompt triggers this behavior. 1Password's password fields, SecurityAgent's privilege escalation dialogs, even certain apps' own Secure Input mode all do it.
For English-only users this is invisible: they're already on ABC. For anyone using a CJK input method, every authentication event silently breaks their input context, with no indication that anything happened.
I searched extensively for prior documentation of this: Apple Developer Forums, Reddit, Stack Overflow, various Chinese and Japanese tech communities. Nobody had traced this specifically to the system auth processes triggering TIS input source changes. The common advice — turn off Caps Lock switching, turn off per-document input sources — addresses different mechanisms entirely.
The Fix: A LaunchAgent That Restores What macOS Forgets
Since macOS won't restore the input source after authentication, the fix is to do it manually.
The first version of the fix enumerated known auth process names (loginwindow, coreautha) and restored the input source when focus returned from them. But this approach had two problems:
- The list is never complete — 1Password,
SecurityAgent, and any future auth process would need to be added manually - Some switches don't involve a focus change — 1Password's password field triggers Secure Input within the app; the frontmost process doesn't change
So I switched from enumerating process names to detecting the behavior. The core logic:
CGEventTapmonitors all keyboard events and records the timestamp of the last keypressDistributedNotificationCenterlistens for TIS input source change notifications- If the input source switches to ABC but there was no keypress in the last 1 second — it's marked as a system-initiated switch that needs restoration
- Restoration happens via two paths: on app focus change (Touch ID scenario) + a 1.5-second delayed fallback for in-app scenarios where focus doesn't change (1Password, etc.)
The restore function uses TISCreateInputSourceList to search all available input sources, matches the saved input source ID, and calls TISSelectInputSource.
The LaunchAgent plist is configured with KeepAlive: true so it starts on login and runs continuously.
What Was Ruled Out
To close the loop: here's everything I verified was not the cause.
- Caps Lock key —
capslock-state.logshowed zero events during unexplained switches - Ctrl+Space — same; the keyboard event log was silent
- iTerm2 tab switching — tested hundreds of times, never triggered an input source switch
- Shift key in Rime — Rime has an internal
ascii_modethat activates on Shift, but this is Rime-internal state; it does not change the macOS TIS input source - BetterTouchTool — I use BTT, so I searched its full SQLite database for any action configured to change input sources; found nothing
- Per-app input source switching (macOS "Automatically switch to a document's input source") — was already disabled; re-verified off
- "Use Caps Lock to switch" setting — was already disabled; re-verified
All paths exhausted. The only events in the log during every unexplained switch were loginwindow and coreautha.
Closing Thought
The thing that sticks with me about this one isn't the fix — the fix is straightforward once you know the cause. It's that macOS has been shipping this behavior for years, affecting every non-English input method user who uses Touch ID regularly, and nobody had documented the actual mechanism.
The forum threads about "input source randomly switching" have existed for a long time. The answers are always the same three suggestions, none of which address this. The reason is that without event-driven TIS monitoring, you can't catch the loginwindow transition — it's too fast, and polling misses it. The problem looked random because the observation tools weren't precise enough.
Five layers of monitoring to isolate one missing restore call in the macOS auth flow. Classic.