• Stars
    star
    162
  • Rank 232,284 (Top 5 %)
  • Language
    Objective-C
  • License
    GNU General Publi...
  • Created about 8 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Frustrated that OS X doesn't have a simple software keyboard debouncer. Here's my hack.

debounce-mac

This is for those annoying moments when you wished that macOS had XkbSetBounceKeysDelay like Linux does.

This is a bog-simple keyboard event tap that intercepts any (identical) keystrokes that happen within a configurable time window. Magic. See here for the genesis story.

Credit where credit is due: i mostly stole this idea and sample code off another StackOverflow answer.

How do?

You should be able to make this work with something like the following:

$ make
$ sudo ./debounce

It needs root because it intercepts keystrokes.

If you really want, you can "install" it. Assuming that /usr/local/bin is in your $PATH (which it is if you use Homebrew) you can:

$ make install

Auto-start at login

Another helpful contribution, this time from @cpouldev. If you'd like to auto-start debounce at login, you might find something like the included LaunchAgent configuration helpful.

Put that somewhere launchctl can find it, like ~/Library/LaunchAgents/com.debounceMac.app.plist, then load the configuration. macOS will automatically prompt you to give debounce Accessibility access, this is needed to be able to intercept and modify keystrokes.

$ launchctl load ~/Library/LaunchAgents/com.debounceMac.app.plist

macOS will automatically prompt you to give debounce Accessibility access, this is needed to be able to intercept and modify keystrokes. When that's done, start it.

$ launchctl start com.debounceMac.app

To remove / uninstall completely:

$ launchctl stop com.debounceMac.app
$ launchctl unload ~/Library/LaunchAgents/com.debounceMac.app.plist
$ rm ~/Library/LaunchAgents/com.debounceMac.app.plist
$ launchctl list
$ rm /usr/local/bin/debounce

Accessibility / permissions

You might get an error something like the following, even when running as root.

$ sudo ./debounce
2019-03-03 10:47:02.194 debounce[59588:499245] Initializing an event tap.
2019-03-03 10:47:02.205 debounce[59588:499245] Unable to create event tap.  Must run as root or add Accessibility privileges to this app.
2019-03-03 10:47:02.205 debounce[59588:499245] No Event tap in place!  You will need to call listen after tapEvents to get events.

@DanGrayson kindly alerted me to the fact that on modern macOS, you'll need to enable universal accessibility features to let this work. It appears that you'll need to go to System Preferences > Privacy > Accessibility, and grant Terminal.app permission, not the debounce binary as you might expect.