Mousekeys is a feature that allows you to emulate a mouse using your keyboard. You can move the pointer around, click up to 5 buttons, and even scroll in all 4 directions. QMK uses the same algorithm as the X Window System MouseKeysAccel feature. You can read more about it on Wikipedia.
There are two steps to adding Mousekeys support to your keyboard. You must enable support in the
rules.mk file and you must map mouse actions to keys on your keyboard.
To add support for Mousekeys you simply need to add a single line to your keymap's
MOUSEKEY_ENABLE = yes
You can see an example here: https://github.com/qmk/qmk_firmware/blob/master/keyboards/clueboard/66/keymaps/mouse_keys/rules.mk
You can use these keycodes within your keymap to map button presses to mouse actions:
Mouse Cursor Up
Mouse Cursor Down
Mouse Cursor Left
Mouse Cursor Right
Mouse Button 1
Mouse Button 2
Mouse Button 3
Mouse Button 4
Mouse Button 5
Mouse Wheel Up
Mouse Wheel Down
Mouse Wheel Left
Mouse Wheel Right
Set mouse acceleration to 0
Set mouse acceleration to 1
Set mouse acceleration to 2
You can see an example in the
_ML here: https://github.com/qmk/qmk_firmware/blob/master/keyboards/clueboard/66/keymaps/mouse_keys/keymap.c#L46
The default speed for controlling the mouse with the keyboard is intentionally slow. You can adjust these parameters by adding these settings to your keymap's
config.h file. All times are specified in milliseconds (ms).
#define MOUSEKEY_DELAY 300#define MOUSEKEY_INTERVAL 50#define MOUSEKEY_MAX_SPEED 10#define MOUSEKEY_TIME_TO_MAX 20#define MOUSEKEY_WHEEL_MAX_SPEED 8#define MOUSEKEY_WHEEL_TIME_TO_MAX 40
When one of the mouse movement buttons is pressed this setting is used to define the delay between that button press and the mouse cursor moving. Some people find that small movements are impossible if this setting is too low, while settings that are too high feel sluggish.
When a movement key is held down this specifies how long to wait between each movement report. Lower settings will translate into an effectively higher mouse speed.
As a movement key is held down the speed of the mouse cursor will increase until it reaches
How long you want to hold down a movement key for until
MOUSEKEY_MAX_SPEED is reached. This controls how quickly your cursor will accelerate.
The top speed for scrolling movements.
How long you want to hold down a scroll key for until
MOUSEKEY_WHEEL_MAX_SPEED is reached. This controls how quickly your scrolling will accelerate.