Tech

Tap Detection on a Lap: Using the Gyroscope to Switch Detection Modes

Tap Detection on a Lap: Using the Gyroscope to Switch Detection Modes

Falcon, Founding Member at Miller

Same gesture. Different surface. A system that adapts so the experience doesn’t have to.

Same gesture. Different surface. A system that adapts so the experience doesn’t have to.

Everything had been tested on desks. Different surfaces, different resonance profiles, different floor materials transmitting vibration differently. It all worked.

Then one of us, in a good mood about the state of things, walked over to the beanbag in the office, sat down with the laptop on their knees, and tapped. Nothing happened. Tapped again. Nothing. Changed the force, the angle, the speed. Nothing.

The problem

On a desk, the laptop sits on a rigid surface. Gravity points mostly down the Z-axis, the X and Y axes are quiet at rest, and the stability gate has clean boundaries to work with.

On a lap, the laptop is on a soft, shifting surface. Your body moves, your legs adjust, you breathe, and the accelerometer sees continuous low-level motion across all three axes. The stability gate, designed to reject exactly this kind of instability, was rejecting everything. Including real taps.

The obvious fix (widen the stability thresholds) doesn't work. The entire purpose of those thresholds is to block surface vibrations, and a lap is, from the sensor's perspective, a continuously vibrating surface. Loosening the gate for laps reopens it for desk vibrations in normal mode.

The answer was not to loosen the gate but to build a second mode with a different gate.

Gyro as environment detector

The accelerometer measures linear acceleration. It's the right sensor for detecting tap impacts. The gyroscope measures rotation. It's the wrong sensor for tap detection but the right one for answering a different question: is the laptop on a stable surface or a shifting one?

The two sensors have cleanly separated roles. The accelerometer detects the tap. The gyroscope decides which set of rules to apply to the detection.

The one-second average of gyro magnitude gives a smoothed measure of how much the device has been rotating.

where W_t is the set of gyro samples in the last one second.

A laptop on a desk has a gyro average near zero. A laptop on a lap has persistent rotational activity from the body underneath.

Hysteresis

Tilt mode uses separate thresholds for activation and deactivation.

\gamma_{off} is set far below \gamma_{on}. This gap is the hysteresis band. Without it, the mode would flicker on and off whenever the gyro average hovers near a single threshold. With it, once tilt mode activates, it stays active until the environment is clearly stable again.

The on-threshold is set above the range where desk vibrations live. A resonant desk can produce gyro activity from transmitted vibrations, but that activity stays well below the on-threshold. Actual lap use, with the continuous rotation from a body underneath, consistently exceeds it. The off-threshold is set low enough that only a genuinely stable surface (back on a desk, device set down and still) will trigger deactivation.

Tilt stability

In tilt mode, the stability gate changes entirely.

The X and Z axis checks are dropped. When the device is tilted, gravity redistributes across these axes. Their ranges become dominated by orientation changes rather than impact energy, making them unreliable indicators of either stability or tap energy.

Only the Y-axis range is retained.

Y remains useful because sliding (pushing the laptop across a surface, or the laptop sliding on your legs) produces very high Y-axis range regardless of tilt angle, while finger taps produce moderate range. The threshold sits between these two distributions. In testing, actual knee-based use produced yR values well below the threshold, while sliding events exceeded it by a wide margin.

Tilt crest

Dropping two axes of stability removes two thirds of the false-positive protection. Something must compensate.

In tilt mode, the crest thresholds are raised significantly. If the system can't verify that the environment is stable, it demands stronger proof that the impulse itself is a finger tap: sharper, more distinct from the surrounding signal.

The triple-tap tilt threshold is lower than the double-tap tilt threshold, for the same reason as in normal mode: a three-tap cadence is itself a strong discriminator, and the crest requirement can be relaxed slightly without increasing false positives.

Both tilt crest thresholds are substantially higher than their normal-mode counterparts. The compensation is necessary because two axes of stability are gone, and without it the system has fewer layers behind crest to catch what crest misses. But the noise that crest guards against is different on a lap. The impulse-like false positives that dominate a desk (return shocks, surface-transmitted vibrations) are largely absent on a lap. What remains is continuous, rotational noise, which stability couldn't handle anyway and which is the reason those axes were dropped. So the stricter crest threshold guards a narrower threat surface, and in practice, dropping two axes of stability removes more false negatives than the stricter crest creates. Based on the noise types we've observed, the harder environment for false positive prevention is the desk, not the lap. That's a design premise, not a measured conclusion. It holds until sustained tilt-mode false positive measurement says otherwise.

Set-down impact guard

One specific failure mode required its own guard. When you pick up a laptop from your lap and set it down on a desk, the impact is large and the gyro activity is high. Without a dedicated check, this reads as a tap in an unstable environment, which is exactly the kind of event tilt mode is designed to accept.

The guard looks for the simultaneous presence of extreme gyro activity and extreme Z-axis range. This combination characterizes a set-down impact and essentially nothing else.

In the logs that motivated this guard, set-down impacts showed gyro and zR values several times larger than anything produced by finger taps on a lap. The separation was wide enough that the threshold could be set conservatively.

The tilt pipeline

The detection path in tilt mode shares most of its structure with normal mode. The entry point is the same (raw accelerometer, delta magnitude, HPF, STA/LTA, candidate energy gate). The guards are the same (typing, cooldown, settling). The timing gate is the same.

The paths diverge at stability and crest. In normal mode, stability checks three axes with bounded ranges and crest uses standard thresholds. In tilt mode, stability checks one axis, adds the set-down guard, and crest uses elevated thresholds.

Everything else is shared. The pipeline doesn't branch into two separate systems. It's one system with a mode switch at two specific layers, governed by a gyro-derived signal that is itself independent of the tap detection logic.

The full pipeline runs continuously in the background. The accelerometer polls at 100 Hz. At that rate, the one-second stability window holds roughly 100 samples per axis, and the 2% trim discards the outermost two on each side before computing range. The STA/LTA baseline is a separate mechanism on a separate window; it has no trim, only the exclusion of the most recent interval described in Part 1. The system is designed to be light enough that the user doesn't notice it's on. Battery and CPU cost are real constraints we've worked within, but the architecture behind that is a separate topic.

What "same every time" asks

This is the part that taught us the most about condition 2.

To the user, tapping the laptop should feel identical whether it's on a desk or on their knees. Same gesture, same response, same timing. There is no reason the user should know or care that the surface changed.

To make that identical experience, the system behind it cannot be identical. It has to detect the environment, switch its rules, compensate for what it lost in the switch, and guard against failure modes that only exist in the new environment. Internally, the system is substantially different in tilt mode. Externally, that's what the mode switch is for. Whether the gap is small enough that the user doesn't feel the difference is a question the numbers below will answer.

"Same every time" is not maintained by internal consistency. It's maintained by internal adaptation. The system changes so that the experience doesn't have to.

The ledger, revisited

Adding tilt mode updates the count from Part 1.

Condition 3 (don't answer uninvited) gains the set-down impact guard and the elevated crest thresholds, both of which exist solely to reject non-tap events that the weakened stability gate can no longer catch.

Condition 1 (answer every time) gains no new mechanism in tilt mode. No new rescue path, no new adaptive gate. Structurally, tilt mode only subtracts and compensates. But measured recall is higher in tilt mode than in normal mode, because the desk is where false positive prevention demands the tightest settings and where most legitimate taps are currently lost. The bottleneck for condition 1 is normal mode, not tilt mode.

Condition 2 (same every time) is no longer just about testing across environments. It's about the system actively reshaping itself per environment. The hysteresis band, the mode-specific gates, the compensating crest thresholds. All of this exists so that the user never has to think about what surface they're on.

Our framework says psychological presence is set by the worst experience, not the average one. A detection system is tuned the same way. You don't optimize for the average case. You find the worst false positive and the worst false negative, and you build the system around making sure neither happens again. Then you find the next worst one.

Two of the three conditions were achievable by deciding. The notch steps back on its own when you're done with it. The notch is in the same place every single time. The first condition could only be earned.

From internal testing by six people over two months across different surfaces, floors, and postures: in normal desk use, unintended activations occurred 5 times across 426 hours of general use. That works out to roughly one every 85 hours, or about once every two to three weeks per person. Recall on a desk is around 86%. On a lap, it rises to around 97%.

Each of those five activations opens Miller's interface. It's dismissible in under a second and doesn't execute any action, so the disruption is low. By our own framework that's still five moments where the tool moved without being called, and five is not zero.

We don't have an equivalent hours-of-use false positive count for tilt mode. The set-down impact guard was built from observed failures, but sustained false positive measurement in tilt mode hasn't been done yet.

The desk is where more impulse-like noise sources live (return shocks, surface-transmitted vibrations), so the desk is where thresholds are intentionally tightest, and where most legitimate taps are lost. The gap between 86% and 97% is how far condition 2 still falls short. It points at normal mode as the bottleneck, not tilt mode.

That tradeoff is the direct result of prioritizing condition 3 over condition 1. But by the standards we set for ourselves, condition 1 isn't met. "Answer every time you call" and "miss roughly one in eight on a desk" don't sit together. This is the gap we need to close next, and closing it without reopening condition 3 is the hardest version of the problem we've described throughout this piece.

Over two thousand test cycles, across desks, floors, laps, and beanbags, was the beginning. Whether it's enough is a question the market answers, not us.