import { _ as _export_sfc, c as createElementBlock, o as openBlock, a8 as createStaticVNode } from "./chunks/framework.DyMmIvSC.js"; const __pageData = JSON.parse('{"title":"Mouse keys","description":"","frontmatter":{},"headers":[],"relativePath":"features/mouse_keys.md","filePath":"features/mouse_keys.md"}'); const _sfc_main = { name: "features/mouse_keys.md" }; const _hoisted_1 = /* @__PURE__ */ createStaticVNode('

Mouse keys

Mouse keys is a feature that allows you to emulate a mouse using your keyboard. You can move the pointer at different speeds, press 5 buttons and scroll in 8 directions.

Adding mouse keys to your keyboard

To use mouse keys, you must at least enable mouse keys support and map mouse actions to keys on your keyboard.

Enabling mouse keys

To enable mouse keys, add the following line to your keymap’s rules.mk:

c
MOUSEKEY_ENABLE = yes

Mapping mouse actions

In your keymap you can use the following keycodes to map key presses to mouse actions:

KeyAliasesDescription
QK_MOUSE_CURSOR_UPMS_UPMouse cursor up
QK_MOUSE_CURSOR_DOWNMS_DOWNMouse cursor down
QK_MOUSE_CURSOR_LEFTMS_LEFTMouse cursor left
QK_MOUSE_CURSOR_RIGHTMS_RGHTMouse cursor right
QK_MOUSE_BUTTON_1MS_BTN1Mouse button 1
QK_MOUSE_BUTTON_2MS_BTN2Mouse button 2
QK_MOUSE_BUTTON_3MS_BTN3Mouse button 3
QK_MOUSE_BUTTON_4MS_BTN4Mouse button 4
QK_MOUSE_BUTTON_5MS_BTN5Mouse button 5
QK_MOUSE_BUTTON_6MS_BTN6Mouse button 6
QK_MOUSE_BUTTON_7MS_BTN7Mouse button 7
QK_MOUSE_BUTTON_8MS_BTN8Mouse button 8
QK_MOUSE_WHEEL_UPMS_WHLUMouse wheel up
QK_MOUSE_WHEEL_DOWNMS_WHLDMouse wheel down
QK_MOUSE_WHEEL_LEFTMS_WHLLMouse wheel left
QK_MOUSE_WHEEL_RIGHTMS_WHLRMouse wheel right
QK_MOUSE_ACCELERATION_0MS_ACL0Set mouse acceleration to 0
QK_MOUSE_ACCELERATION_1MS_ACL1Set mouse acceleration to 1
QK_MOUSE_ACCELERATION_2MS_ACL2Set mouse acceleration to 2

Configuring mouse keys

Mouse keys supports three different modes to move the cursor:

The same principle applies to scrolling, in most modes.

Configuration options that are times, intervals or delays are given in milliseconds. Scroll speed is given as multiples of the default scroll step. For example, a scroll speed of 8 means that each scroll action covers 8 times the length of the default scroll step as defined by your operating system or application.

Accelerated mode

This is the default mode. You can adjust the cursor and scrolling acceleration using the following settings in your keymap’s config.h file:

DefineDefaultDescription
MOUSEKEY_DELAY10Delay between pressing a movement key and cursor movement
MOUSEKEY_INTERVAL20Time between cursor movements in milliseconds
MOUSEKEY_MOVE_DELTA8Step size
MOUSEKEY_MAX_SPEED10Maximum cursor speed at which acceleration stops
MOUSEKEY_TIME_TO_MAX30Time until maximum cursor speed is reached
MOUSEKEY_WHEEL_DELAY10Delay between pressing a wheel key and wheel movement
MOUSEKEY_WHEEL_INTERVAL80Time between wheel movements
MOUSEKEY_WHEEL_DELTA1Wheel movement step size
MOUSEKEY_WHEEL_MAX_SPEED8Maximum number of scroll steps per scroll action
MOUSEKEY_WHEEL_TIME_TO_MAX40Time until maximum scroll speed is reached

Tips:

Cursor acceleration uses the same algorithm as the X Window System MouseKeysAccel feature. You can read more about it on Wikipedia.

Kinetic Mode

This is an extension of the accelerated mode. The kinetic mode uses a quadratic curve on the cursor speed which allows precise movements at the beginning and allows to cover large distances by increasing cursor speed quickly thereafter. You can adjust the cursor and scrolling acceleration using the following settings in your keymap’s config.h file:

DefineDefaultDescription
MK_KINETIC_SPEEDundefinedEnable kinetic mode
MOUSEKEY_DELAY5Delay between pressing a movement key and cursor movement
MOUSEKEY_INTERVAL10Time between cursor movements in milliseconds
MOUSEKEY_MOVE_DELTA16Step size for accelerating from initial to base speed
MOUSEKEY_INITIAL_SPEED100Initial speed of the cursor in pixel per second
MOUSEKEY_BASE_SPEED5000Maximum cursor speed at which acceleration stops
MOUSEKEY_DECELERATED_SPEED400Decelerated cursor speed
MOUSEKEY_ACCELERATED_SPEED3000Accelerated cursor speed
MOUSEKEY_WHEEL_INITIAL_MOVEMENTS16Initial number of movements of the mouse wheel
MOUSEKEY_WHEEL_BASE_MOVEMENTS32Maximum number of movements at which acceleration stops
MOUSEKEY_WHEEL_ACCELERATED_MOVEMENTS48Accelerated wheel movements
MOUSEKEY_WHEEL_DECELERATED_MOVEMENTS8Decelerated wheel movements

Tips:

Constant mode

In this mode you can define multiple different speeds for both the cursor and the mouse wheel. There is no acceleration. MS_ACL0, MS_ACL1 and MS_ACL2 change the cursor and scroll speed to their respective setting.

You can choose whether speed selection is momentary or tap-to-select:

The default speeds from slowest to fastest are as follows:

To use constant speed mode, you must at least define MK_3_SPEED in your keymap’s config.h file:

c
#define MK_3_SPEED

To enable momentary mode, also define MK_MOMENTARY_ACCEL:

c
#define MK_MOMENTARY_ACCEL

Use the following settings if you want to adjust cursor movement or scrolling:

DefineDefaultDescription
MK_3_SPEEDNot definedEnable constant cursor speeds
MK_MOMENTARY_ACCELNot definedEnable momentary speed selection
MK_C_OFFSET_UNMOD16Cursor offset per movement (unmodified)
MK_C_INTERVAL_UNMOD16Time between cursor movements (unmodified)
MK_C_OFFSET_01Cursor offset per movement (MS_ACL0)
MK_C_INTERVAL_032Time between cursor movements (MS_ACL0)
MK_C_OFFSET_14Cursor offset per movement (MS_ACL1)
MK_C_INTERVAL_116Time between cursor movements (MS_ACL1)
MK_C_OFFSET_232Cursor offset per movement (MS_ACL2)
MK_C_INTERVAL_216Time between cursor movements (MS_ACL2)
MK_W_OFFSET_UNMOD1Scroll steps per scroll action (unmodified)
MK_W_INTERVAL_UNMOD40Time between scroll steps (unmodified)
MK_W_OFFSET_01Scroll steps per scroll action (MS_ACL0)
MK_W_INTERVAL_0360Time between scroll steps (MS_ACL0)
MK_W_OFFSET_11Scroll steps per scroll action (MS_ACL1)
MK_W_INTERVAL_1120Time between scroll steps (MS_ACL1)
MK_W_OFFSET_21Scroll steps per scroll action (MS_ACL2)
MK_W_INTERVAL_220Time between scroll steps (MS_ACL2)

Combined mode

This mode functions like Accelerated mode, however, you can hold MS_ACL0, MS_ACL1 and MS_ACL2 to momentarily (while held) set the cursor and scroll speeds to constant speeds. When no acceleration keys are held, this mode is identical to Accelerated mode, and can be modified using all of the relevant settings.

To use combined speed mode, you must at least define MK_COMBINED in your keymap’s config.h file:

c
#define MK_COMBINED

Inertia mode

This mode provides smooth motion, like sliding on ice. The cursor accelerates along a quadratic curve while a key is held, then glides to a stop after the key is released. Vertical and horizontal movements are tracked independently, so the cursor can move in many directions and make curves.

Cannot be used at the same time as Kinetic mode, Constant mode, or Combined mode.

Recommended settings in your keymap’s config.h file:

DefineDefaultDescription
MOUSEKEY_INERTIAundefinedEnable Inertia mode
MOUSEKEY_DELAY150Delay between pressing a movement key and cursor movement
MOUSEKEY_INTERVAL16Time between cursor movements in milliseconds (16 = 60fps)
MOUSEKEY_MAX_SPEED32Maximum cursor speed at which acceleration stops
MOUSEKEY_TIME_TO_MAX32Number of frames until maximum cursor speed is reached
MOUSEKEY_FRICTION24How quickly the cursor stops after releasing a key
MOUSEKEY_MOVE_DELTA1How much to move on first frame (1 strongly recommended)

Tips:

Overlapping mouse key control

When additional overlapping mouse key is pressed, the mouse cursor will continue in a new direction with the same acceleration. The following settings can be used to reset the acceleration with new overlapping keys for more precise control if desired:

DefineDefaultDescription
MOUSEKEY_OVERLAP_RESETundefinedEnables overlapping mouse key control
MOUSEKEY_OVERLAP_MOVE_DELTAMOUSEKEY_MOVE_DELTAStep size of reset movement acceleration
MOUSEKEY_OVERLAP_WHEEL_DELTAMOUSEKEY_WHEEL_DELTAStep size of reset mouse wheel acceleration
MOUSEKEY_OVERLAP_INTERVALMOUSEKEY_INTERVALReset time between cursor movements in milliseconds (Kinetic mode only)

?> This feature will not be applied on Inertial mode

Use with PS/2 Mouse and Pointing Device

Mouse keys button state is shared with PS/2 mouse and pointing device so mouse keys button presses can be used for clicks and drags.

', 56); const _hoisted_57 = [ _hoisted_1 ]; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return openBlock(), createElementBlock("div", null, _hoisted_57); } const mouse_keys = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]); export { __pageData, mouse_keys as default };