Using a Laptop Chassis as an Input Device
Most input devices assume distance. Your hands move to a keyboard, a trackpad, a mouse. I was interested in the opposite idea. What if the machine itself was the interface. Not through touch gestures, but through physical knocks on the chassis.
That question turned into KnockFree, a macOS menu bar app that reads the built in accelerometer on Apple Silicon MacBooks and maps knock patterns to actions. Single, double, and triple knocks can trigger media controls, launch apps, switch desktops, or run scripts. The interesting part was not the action system. It was making knock detection reliable enough to trust.
Signal Before Features
The core decision was to treat this as a signal processing problem before treating it as an automation app. Raw accelerometer data includes gravity and constant low level movement. Reading values directly was noisy and not useful.
The better approach was first difference filtering. I compared each sample to the previous one and used change, not raw position, as the signal. That made knocks show up as impulses while ignoring static gravity and slow movement. It was a small mathematical shift that made the whole project viable.
- Accelerometer samples came through IOKit HID at roughly 100 Hz
- An 80 millisecond debounce stopped one knock from registering multiple times
- A 500 millisecond gesture window classified single, double, and triple knocks
That classification layer was simple, but timing mattered a lot. Small changes in thresholds made the system feel either responsive or unusable.
System Integration Was the Hard Part
Reading the sensor was only half the work. The harder part was making the app behave like a native utility. It runs without a Dock icon, lives in the menu bar, stores bindings in UserDefaults, and posts system events for media keys and desktop switching.
Typing created a false positive problem early on. Knocks from keyboard impact would occasionally trigger gestures. I added a suppression filter using a system event tap that pauses detection briefly after key presses. That feature was not flashy, but it made the app feel much less fragile.
One feature I kept because it was fun was the Iron Man preset. It launches my development stack in sequence with timed delays. Slightly ridiculous. Also useful.
What Did Not Work Cleanly
Some parts are rough. Accessing the accelerometer depends on an undocumented HID report format. It works, but it is reverse engineered and could break with OS changes. That is a real limitation.
I also wanted location aware knocks, like detecting whether the tap happened near the palm rest or screen hinge. I did not solve that. The current model only treats knocks as impulse events, not spatial events.
If I rebuilt it, I would spend more time on adaptive thresholds instead of static sensitivity settings. Different surfaces change the feel of knock detection more than I expected.
What I Learned
The biggest lesson was that good interaction design sometimes starts below the UI layer. A menu, settings panel, and presets matter, but the project stood or fell on whether one physical knock produced one intentional response.
Hardware quirks make good software questions.