You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

208 lines
14 KiB

  1. # Mouse keys
  2. 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.
  3. ## Adding mouse keys to your keyboard
  4. To use mouse keys, you must at least enable mouse keys support and map mouse actions to keys on your keyboard.
  5. ### Enabling mouse keys
  6. To enable mouse keys, add the following line to your keymapโ€™s `rules.mk`:
  7. ```c
  8. MOUSEKEY_ENABLE = yes
  9. ```
  10. ### Mapping mouse actions
  11. In your keymap you can use the following keycodes to map key presses to mouse actions:
  12. |Key |Aliases |Description |
  13. |----------------|---------|-----------------|
  14. |`KC_MS_UP` |`KC_MS_U`|Move cursor up |
  15. |`KC_MS_DOWN` |`KC_MS_D`|Move cursor down |
  16. |`KC_MS_LEFT` |`KC_MS_L`|Move cursor left |
  17. |`KC_MS_RIGHT` |`KC_MS_R`|Move cursor right|
  18. |`KC_MS_BTN1` |`KC_BTN1`|Press button 1 |
  19. |`KC_MS_BTN2` |`KC_BTN2`|Press button 2 |
  20. |`KC_MS_BTN3` |`KC_BTN3`|Press button 3 |
  21. |`KC_MS_BTN4` |`KC_BTN4`|Press button 4 |
  22. |`KC_MS_BTN5` |`KC_BTN5`|Press button 5 |
  23. |`KC_MS_BTN6` |`KC_BTN6`|Press button 6 |
  24. |`KC_MS_BTN7` |`KC_BTN7`|Press button 7 |
  25. |`KC_MS_BTN8` |`KC_BTN8`|Press button 8 |
  26. |`KC_MS_WH_UP` |`KC_WH_U`|Move wheel up |
  27. |`KC_MS_WH_DOWN` |`KC_WH_D`|Move wheel down |
  28. |`KC_MS_WH_LEFT` |`KC_WH_L`|Move wheel left |
  29. |`KC_MS_WH_RIGHT`|`KC_WH_R`|Move wheel right |
  30. |`KC_MS_ACCEL0` |`KC_ACL0`|Set speed to 0 |
  31. |`KC_MS_ACCEL1` |`KC_ACL1`|Set speed to 1 |
  32. |`KC_MS_ACCEL2` |`KC_ACL2`|Set speed to 2 |
  33. ## Configuring mouse keys
  34. Mouse keys supports three different modes to move the cursor:
  35. * **Accelerated (default):** Holding movement keys accelerates the cursor until it reaches its maximum speed.
  36. * **Kinetic:** Holding movement keys accelerates the cursor with its speed following a quadratic curve until it reaches its maximum speed.
  37. * **Constant:** Holding movement keys moves the cursor at constant speeds.
  38. * **Combined:** Holding movement keys accelerates the cursor until it reaches its maximum speed, but holding acceleration and movement keys simultaneously moves the cursor at constant speeds.
  39. * **Inertia:** Cursor accelerates when key held, and decelerates after key release. Tracks X and Y velocity separately for more nuanced movements. Applies to cursor only, not scrolling.
  40. The same principle applies to scrolling, in most modes.
  41. 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.
  42. ### Accelerated mode
  43. This is the default mode. You can adjust the cursor and scrolling acceleration using the following settings in your keymapโ€™s `config.h` file:
  44. |Define |Default|Description |
  45. |----------------------------|-------|---------------------------------------------------------|
  46. |`MOUSEKEY_DELAY` |10 |Delay between pressing a movement key and cursor movement|
  47. |`MOUSEKEY_INTERVAL` |20 |Time between cursor movements in milliseconds |
  48. |`MOUSEKEY_MOVE_DELTA` |8 |Step size |
  49. |`MOUSEKEY_MAX_SPEED` |10 |Maximum cursor speed at which acceleration stops |
  50. |`MOUSEKEY_TIME_TO_MAX` |30 |Time until maximum cursor speed is reached |
  51. |`MOUSEKEY_WHEEL_DELAY` |10 |Delay between pressing a wheel key and wheel movement |
  52. |`MOUSEKEY_WHEEL_INTERVAL` |80 |Time between wheel movements |
  53. |`MOUSEKEY_WHEEL_DELTA` |1 |Wheel movement step size |
  54. |`MOUSEKEY_WHEEL_MAX_SPEED` |8 |Maximum number of scroll steps per scroll action |
  55. |`MOUSEKEY_WHEEL_TIME_TO_MAX`|40 |Time until maximum scroll speed is reached |
  56. Tips:
  57. * Setting `MOUSEKEY_DELAY` too low makes the cursor unresponsive. Setting it too high makes small movements difficult.
  58. * 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`.
  59. * 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.
  60. * Setting `MOUSEKEY_WHEEL_INTERVAL` too low will make scrolling too fast. Setting it too high will make scrolling too slow when the wheel key is held down.
  61. Cursor 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).
  62. ### Kinetic Mode
  63. 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:
  64. |Define |Default |Description |
  65. |--------------------------------------|---------|---------------------------------------------------------------|
  66. |`MK_KINETIC_SPEED` |undefined|Enable kinetic mode |
  67. |`MOUSEKEY_DELAY` |5 |Delay between pressing a movement key and cursor movement |
  68. |`MOUSEKEY_INTERVAL` |10 |Time between cursor movements in milliseconds |
  69. |`MOUSEKEY_MOVE_DELTA` |16 |Step size for accelerating from initial to base speed |
  70. |`MOUSEKEY_INITIAL_SPEED` |100 |Initial speed of the cursor in pixel per second |
  71. |`MOUSEKEY_BASE_SPEED` |5000 |Maximum cursor speed at which acceleration stops |
  72. |`MOUSEKEY_DECELERATED_SPEED` |400 |Decelerated cursor speed |
  73. |`MOUSEKEY_ACCELERATED_SPEED` |3000 |Accelerated cursor speed |
  74. |`MOUSEKEY_WHEEL_INITIAL_MOVEMENTS` |16 |Initial number of movements of the mouse wheel |
  75. |`MOUSEKEY_WHEEL_BASE_MOVEMENTS` |32 |Maximum number of movements at which acceleration stops |
  76. |`MOUSEKEY_WHEEL_ACCELERATED_MOVEMENTS`|48 |Accelerated wheel movements |
  77. |`MOUSEKEY_WHEEL_DECELERATED_MOVEMENTS`|8 |Decelerated wheel movements |
  78. Tips:
  79. * The smoothness of the cursor movement depends on the `MOUSEKEY_INTERVAL` setting. The shorter the interval is set the smoother the movement will be. Setting the value too low makes the cursor unresponsive. Lower settings are possible if the micro processor is fast enough. For example: At an interval of `8` milliseconds, `125` movements per second will be initiated. With a base speed of `1000` each movement will move the cursor by `8` pixels.
  80. * Mouse wheel movements are implemented differently from cursor movements. While it's okay for the cursor to move multiple pixels at once for the mouse wheel this would lead to jerky movements. Instead, the mouse wheel operates at step size `1`. Setting mouse wheel speed is done by adjusting the number of wheel movements per second.
  81. ### Constant mode
  82. In 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.
  83. You can choose whether speed selection is momentary or tap-to-select:
  84. * **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.
  85. * **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.
  86. The default speeds from slowest to fastest are as follows:
  87. * **Momentary:** `KC_ACL0` < `KC_ACL1` < *unmodified* < `KC_ACL2`
  88. * **Tap-to-select:** `KC_ACL0` < `KC_ACL1` < `KC_ACL2`
  89. To use constant speed mode, you must at least define `MK_3_SPEED` in your keymapโ€™s `config.h` file:
  90. ```c
  91. #define MK_3_SPEED
  92. ```
  93. To enable momentary mode, also define `MK_MOMENTARY_ACCEL`:
  94. ```c
  95. #define MK_MOMENTARY_ACCEL
  96. ```
  97. Use the following settings if you want to adjust cursor movement or scrolling:
  98. |Define |Default |Description |
  99. |---------------------|-------------|-------------------------------------------|
  100. |`MK_3_SPEED` |*Not defined*|Enable constant cursor speeds |
  101. |`MK_MOMENTARY_ACCEL` |*Not defined*|Enable momentary speed selection |
  102. |`MK_C_OFFSET_UNMOD` |16 |Cursor offset per movement (unmodified) |
  103. |`MK_C_INTERVAL_UNMOD`|16 |Time between cursor movements (unmodified) |
  104. |`MK_C_OFFSET_0` |1 |Cursor offset per movement (`KC_ACL0`) |
  105. |`MK_C_INTERVAL_0` |32 |Time between cursor movements (`KC_ACL0`) |
  106. |`MK_C_OFFSET_1` |4 |Cursor offset per movement (`KC_ACL1`) |
  107. |`MK_C_INTERVAL_1` |16 |Time between cursor movements (`KC_ACL1`) |
  108. |`MK_C_OFFSET_2` |32 |Cursor offset per movement (`KC_ACL2`) |
  109. |`MK_C_INTERVAL_2` |16 |Time between cursor movements (`KC_ACL2`) |
  110. |`MK_W_OFFSET_UNMOD` |1 |Scroll steps per scroll action (unmodified)|
  111. |`MK_W_INTERVAL_UNMOD`|40 |Time between scroll steps (unmodified) |
  112. |`MK_W_OFFSET_0` |1 |Scroll steps per scroll action (`KC_ACL0`) |
  113. |`MK_W_INTERVAL_0` |360 |Time between scroll steps (`KC_ACL0`) |
  114. |`MK_W_OFFSET_1` |1 |Scroll steps per scroll action (`KC_ACL1`) |
  115. |`MK_W_INTERVAL_1` |120 |Time between scroll steps (`KC_ACL1`) |
  116. |`MK_W_OFFSET_2` |1 |Scroll steps per scroll action (`KC_ACL2`) |
  117. |`MK_W_INTERVAL_2` |20 |Time between scroll steps (`KC_ACL2`) |
  118. ### Combined mode
  119. This mode functions like **Accelerated** mode, however, you can hold `KC_ACL0`, `KC_ACL1` and `KC_ACL2`
  120. to momentarily (while held) set the cursor and scroll speeds to constant speeds. When no acceleration
  121. keys are held, this mode is identical to **Accelerated** mode, and can be modified using all of the
  122. relevant settings.
  123. * **KC_ACL0:** This acceleration sets your cursor to the slowest possible speed. This is useful for very
  124. small and detailed movements of the cursor.
  125. * **KC_ACL1:** This acceleration sets your cursor to half the maximum (user defined) speed.
  126. * **KC_ACL2:** This acceleration sets your cursor to the maximum (computer defined) speed. This is
  127. useful for moving the cursor large distances without much accuracy.
  128. To use combined speed mode, you must at least define `MK_COMBINED` in your keymapโ€™s `config.h` file:
  129. ```c
  130. #define MK_COMBINED
  131. ```
  132. ### Inertia mode
  133. This mode provides smooth motion, like sliding on ice. The cursor accelerates
  134. along a quadratic curve while a key is held, then glides to a stop after the
  135. key is released. Vertical and horizontal movements are tracked independently,
  136. so the cursor can move in many directions and make curves.
  137. Cannot be used at the same time as Kinetic mode, Constant mode, or Combined mode.
  138. Recommended settings in your keymapโ€™s `config.h` file:
  139. |Define |Default |Description |
  140. |----------------------------|---------|-----------------------------------------------------------|
  141. |`MOUSEKEY_INERTIA` |undefined|Enable Inertia mode |
  142. |`MOUSEKEY_DELAY` |150 |Delay between pressing a movement key and cursor movement |
  143. |`MOUSEKEY_INTERVAL` |16 |Time between cursor movements in milliseconds (16 = 60fps) |
  144. |`MOUSEKEY_MAX_SPEED` |32 |Maximum cursor speed at which acceleration stops |
  145. |`MOUSEKEY_TIME_TO_MAX` |32 |Number of frames until maximum cursor speed is reached |
  146. |`MOUSEKEY_FRICTION` |24 |How quickly the cursor stops after releasing a key |
  147. |`MOUSEKEY_MOVE_DELTA` |1 |How much to move on first frame (1 strongly recommended) |
  148. Tips:
  149. * Set `MOUSEKEY_DELAY` to roughly the same value as your host computer's key repeat delay, in ms. Recommended values are 100 to 300.
  150. * Set `MOUSEKEY_INTERVAL` to a value of 1000 / your monitor's FPS. For 60 FPS, 1000/60 = 16.
  151. * Set `MOUSEKEY_MAX_SPEED` based on your screen resolution and refresh rate, like Width / FPS. For example, 1920 pixels / 60 FPS = 32 pixels per frame.
  152. * Set `MOUSEKEY_TIME_TO_MAX` to a value of approximately FPS / 2, to make it reach full speed in half a second (or so).
  153. * Set `MOUSEKEY_FRICTION` to something between 1 and 255. Lower makes the cursor glide longer. Values from 8 to 40 are the most effective.
  154. * Keep `MOUSEKEY_MOVE_DELTA` at 1. This allows precise movements before the gliding effect starts.
  155. * Mouse wheel options are the same as the default accelerated mode, and do not use inertia.
  156. ## Use with PS/2 Mouse and Pointing Device
  157. Mouse keys button state is shared with [PS/2 mouse](feature_ps2_mouse.md) and [pointing device](feature_pointing_device.md) so mouse keys button presses can be used for clicks and drags.