Extend maximum number of backlight levels to 31 (#6351)
[jackhill/qmk/firmware.git] / docs / feature_mouse_keys.md
CommitLineData
e3a94002 1# Mouse keys
18bc47eb 2
4856552f 3Mouse 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.
18bc47eb 4
e3a94002 5## Adding mouse keys to your keyboard
18bc47eb 6
e3a94002 7To use mouse keys, you must at least enable mouse keys support and map mouse actions to keys on your keyboard.
b2222053 8
e3a94002 9### Enabling mouse keys
b2222053 10
e3a94002 11To enable mouse keys, add the following line to your keymap’s `rules.mk`:
b2222053 12
e3a94002 13```c
b2222053 14MOUSEKEY_ENABLE = yes
15```
16
e3a94002 17### Mapping mouse actions
b2222053 18
e3a94002 19In your keymap you can use the following keycodes to map key presses to mouse actions:
b2222053 20
e3a94002
MW
21|Key |Aliases |Description |
22|----------------|---------|-----------------|
23|`KC_MS_UP` |`KC_MS_U`|Move cursor up |
24|`KC_MS_DOWN` |`KC_MS_D`|Move cursor down |
25|`KC_MS_LEFT` |`KC_MS_L`|Move cursor left |
26|`KC_MS_RIGHT` |`KC_MS_R`|Move cursor right|
27|`KC_MS_BTN1` |`KC_BTN1`|Press button 1 |
28|`KC_MS_BTN2` |`KC_BTN2`|Press button 2 |
29|`KC_MS_BTN3` |`KC_BTN3`|Press button 3 |
30|`KC_MS_BTN4` |`KC_BTN4`|Press button 4 |
31|`KC_MS_BTN5` |`KC_BTN5`|Press button 5 |
32|`KC_MS_WH_UP` |`KC_WH_U`|Move wheel up |
33|`KC_MS_WH_DOWN` |`KC_WH_D`|Move wheel down |
34|`KC_MS_WH_LEFT` |`KC_WH_L`|Move wheel left |
35|`KC_MS_WH_RIGHT`|`KC_WH_R`|Move wheel right |
36|`KC_MS_ACCEL0` |`KC_ACL0`|Set speed to 0 |
37|`KC_MS_ACCEL1` |`KC_ACL1`|Set speed to 1 |
38|`KC_MS_ACCEL2` |`KC_ACL2`|Set speed to 2 |
346cbd88 39
e3a94002 40## Configuring mouse keys
346cbd88 41
e3a94002 42Mouse keys supports two different modes to move the cursor:
b2222053 43
e3a94002
MW
44* **Accelerated (default):** Holding movement keys accelerates the cursor until it reaches its maximum speed.
45* **Constant:** Holding movement keys moves the cursor at constant speeds.
18bc47eb 46
e3a94002 47The same principle applies to scrolling.
0605107f 48
e3a94002 49Configuration 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.
b2222053 50
e3a94002 51### Accelerated mode
b2222053 52
e3a94002 53This is the default mode. You can adjust the cursor and scrolling acceleration using the following settings in your keymap’s `config.h` file:
b2222053 54
e3a94002
MW
55|Define |Default|Description |
56|----------------------------|-------|---------------------------------------------------------|
57|`MOUSEKEY_DELAY` |300 |Delay between pressing a movement key and cursor movement|
58|`MOUSEKEY_INTERVAL` |50 |Time between cursor movements |
59|`MOUSEKEY_MAX_SPEED` |10 |Maximum cursor speed at which acceleration stops |
60|`MOUSEKEY_TIME_TO_MAX` |20 |Time until maximum cursor speed is reached |
61|`MOUSEKEY_WHEEL_MAX_SPEED` |8 |Maximum number of scroll steps per scroll action |
62|`MOUSEKEY_WHEEL_TIME_TO_MAX`|40 |Time until maximum scroll speed is reached |
b2222053 63
e3a94002 64Tips:
b2222053 65
e3a94002
MW
66* Setting `MOUSEKEY_DELAY` too low makes the cursor unresponsive. Setting it too high makes small movements difficult.
67* For smoother cursor movements, lower the value of `MOUSEKEY_INTERVAL`. If the refresh rate of your display is 60Hz, you could set it to `16` (1/60). As this raises the cursor speed significantly, you may want to lower `MOUSEKEY_MAX_SPEED`.
68* Setting `MOUSEKEY_TIME_TO_MAX` or `MOUSEKEY_WHEEL_TIME_TO_MAX` to `0` will disable acceleration for the cursor or scrolling respectively. This way you can make one of them constant while keeping the other accelerated, which is not possible in constant speed mode.
b2222053 69
e3a94002 70Cursor acceleration uses the same algorithm as the X Window System MouseKeysAccel feature. You can read more about it [on Wikipedia](https://en.wikipedia.org/wiki/Mouse_keys).
b2222053 71
e3a94002 72### Constant mode
b2222053 73
e3a94002 74In this mode you can define multiple different speeds for both the cursor and the mouse wheel. There is no acceleration. `KC_ACL0`, `KC_ACL1` and `KC_ACL2` change the cursor and scroll speed to their respective setting.
b2222053 75
e3a94002 76You can choose whether speed selection is momentary or tap-to-select:
b2222053 77
e3a94002
MW
78* **Momentary:** The chosen speed is only active while you hold the respective key. When the key is raised, mouse keys returns to the unmodified speed.
79* **Tap-to-select:** The chosen speed is activated when you press the respective key and remains active even after the key has been raised. The default speed is that of `KC_ACL1`. There is no unmodified speed.
b2222053 80
e3a94002 81The default speeds from slowest to fastest are as follows:
346cbd88 82
e3a94002
MW
83* **Momentary:** `KC_ACL0` < `KC_ACL1` < *unmodified* < `KC_ACL2`
84* **Tap-to-select:** `KC_ACL0` < `KC_ACL1` < `KC_ACL2`
346cbd88 85
e3a94002 86To use constant speed mode, you must at least define `MK_3_SPEED` in your keymap’s `config.h` file:
346cbd88 87
e3a94002 88```c
346cbd88
JA
89#define MK_3_SPEED
90```
346cbd88 91
e3a94002 92To enable momentary mode, also define `MK_MOMENTARY_ACCEL`:
346cbd88 93
e3a94002
MW
94```c
95#define MK_MOMENTARY_ACCEL
346cbd88
JA
96```
97
e3a94002
MW
98Use the following settings if you want to adjust cursor movement or scrolling:
99
100|Define |Default |Description |
101|---------------------|-------------|-------------------------------------------|
102|`MK_3_SPEED` |*Not defined*|Enable constant cursor speeds |
103|`MK_MOMENTARY_ACCEL` |*Not defined*|Enable momentary speed selection |
104|`MK_C_OFFSET_UNMOD` |16 |Cursor offset per movement (unmodified) |
105|`MK_C_INTERVAL_UNMOD`|16 |Time between cursor movements (unmodified) |
106|`MK_C_OFFSET_0` |1 |Cursor offset per movement (`KC_ACL0`) |
107|`MK_C_INTERVAL_0` |32 |Time between cursor movements (`KC_ACL0`) |
108|`MK_C_OFFSET_1` |4 |Cursor offset per movement (`KC_ACL1`) |
109|`MK_C_INTERVAL_1` |16 |Time between cursor movements (`KC_ACL1`) |
110|`MK_C_OFFSET_2` |32 |Cursor offset per movement (`KC_ACL2`) |
111|`MK_C_INTERVAL_2` |16 |Time between cursor movements (`KC_ACL2`) |
112|`MK_W_OFFSET_UNMOD` |1 |Scroll steps per scroll action (unmodified)|
113|`MK_W_INTERVAL_UNMOD`|40 |Time between scroll steps (unmodified) |
114|`MK_W_OFFSET_0` |1 |Scroll steps per scroll action (`KC_ACL0`) |
115|`MK_W_INTERVAL_0` |360 |Time between scroll steps (`KC_ACL0`) |
116|`MK_W_OFFSET_1` |1 |Scroll steps per scroll action (`KC_ACL1`) |
117|`MK_W_INTERVAL_1` |120 |Time between scroll steps (`KC_ACL1`) |
118|`MK_W_OFFSET_2` |1 |Scroll steps per scroll action (`KC_ACL2`) |
119|`MK_W_INTERVAL_2` |20 |Time between scroll steps (`KC_ACL2`) |