← More about keyboards

This post describes a QMK macro “Turbo Click” button that clicks the mouse rapidly:

Turbo Click may be advantageous in certain computer games. It could also be used in art programs to paint in a dashed pattern. I don’t know that there is a “serious” use for Turbo Click, but it is interesting how auto-repeating actions like this can be implemented in QMK.

Add it to your keymap

If you are new to QMK macros, see my macro buttons post for an intro.

Step 1: In your keymap.c, add a custom keycode for activating Turbo Click and use the new keycode somewhere in your layout. I’ll name it TURBO, but you can call it anything you like.

enum custom_keycodes {
  // Other custom keys...

Step 2: Handle Turbo Click from your process_record_user() function by calling process_mouse_turbo_click(), passing your custom keycode as the third argument:

#include "features/mouse_turbo_click.h"

bool process_record_user(uint16_t keycode, keyrecord_t* record) {
  if (!process_mouse_turbo_click(keycode, record, TURBO)) { return false; }
  // Your macros ...

  return true;

Step 3: In your rules.mk file, add

SRC += features/mouse_turbo_click.c


Step 4: In the directory containing your keymap.c, create a features subdirectory and copy mouse_turbo_click.h and mouse_turbo_click.c there.


The implementation uses mouse keys and a periodic callback using the deferred execution API. When Turbo Click starts, turbo_click_callback() is scheduled. The callback executes twice per click, alternating between pressing and releasing the left mouse button key (KC_MS_BTN1). When Turbo Click stops, the callback is canceled and the mouse button is released if needed.

The constant CLICK_PERIOD_MS determines the click period in units of milliseconds. The configured period of 80 ms gives 1000/80 = 12.5 clicks per second. Smaller period implies faster clicking. Beware that the keyboard might become unresponsive if the period is too small. I suggest setting this no smaller than 10.

← More about keyboards