MacOS – How to Debounce Mechanical Keyboard

keyboardmacos

My work has me back on a Mac. I am using my mechanical keyboard (USB, Cherry blue switches, not that that's important) with OS X. The problem though, is that I get relatively frequent "bouncing" or "chatter" of the keystrokes. For example, if I type hello something like heello might appear. This is rather annoying, especially when entering passwords.

Under Linux I could solve this in software by debouncing, using the xkbsetbouncekeysdelay setting, which adds a minimum number of milliseconds, e.g. 40ms, between key presses. Rather a blunt tool but solves the problem perfectly. However, I haven't been able to find an analogue under OS X.

Does anyone have any software based suggestions? Am I overlooking a simple plist setting somewhere?

Best Answer

I had actually forgotten about this, but a recent comment prompted me to post the solution I ended up going with. Since macOS does not provide a debouncing facility, I ended up writing my own [1]. It hooks into keypresses using a CGEventTap, and if the most recent keypress keycode is equal to the current one, with a timestamp more recent than ±30ms, it disregards it as a bounce.

I apologise for the rough and ready state of the tool, but compile it with the Makefile (you'll need XCode or Developer Tools or whatever they're called these days), and run it using sudo ./debounce (root permissions are necessary because it hooks into all keypresses). It works and has worked for me for the last year-ish, but use at your own risk, free of charge, free of warranty.

  1. https://github.com/toothbrush/debounce-mac/