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.

156 lines
5.7 KiB

  1. # Caps Word
  2. It is often useful to type a single word in all capitals, for instance
  3. abbreviations like "QMK", or in code, identifiers like `KC_SPC`. "Caps Word" is
  4. a modern alternative to Caps Lock:
  5. * Letters are capitalized while active, and Caps Word automatically disables
  6. itself at the end of the word. That is, it stops by default once a space or
  7. any key other than `a`--`z`, `0`--`9`, `-`, `_`, delete, or backspace is
  8. pressed. Caps Word also disables itself if the keyboard is idle for 5 seconds.
  9. This is configurable, see below.
  10. * To avoid requiring a dedicated key for Caps Word, there is an option
  11. (`BOTH_SHIFTS_TURNS_ON_CAPS_WORD`) to activate Caps Word by simultaneously
  12. pressing both shift keys. See below for other options.
  13. * The implementation does not use the Caps Lock (`KC_CAPS`) keycode. Caps Word
  14. works even if you're remapping Caps Lock at the OS level to Ctrl or something
  15. else, as Emacs and Vim users often do.
  16. ## How do I enable Caps Word :id=how-do-i-enable-caps-word
  17. In your `rules.mk`, add:
  18. ```make
  19. CAPS_WORD_ENABLE = yes
  20. ```
  21. Next, use one the following methods to activate Caps Word:
  22. * **Activate by pressing a key**: Use the `CAPS_WORD` keycode (short
  23. alias `CAPSWRD`) in your keymap.
  24. * **Activate by pressing Left Shift + Right Shift**: Add `#define
  25. BOTH_SHIFTS_TURNS_ON_CAPS_WORD` to config.h. You may also need to disable or
  26. reconfigure Command, details below. Then, simultaneously pressing both left
  27. and right shifts turns on Caps Word. This method works with the plain
  28. `KC_LSFT` and `KC_RSFT` keycodes as well as one-shot shifts and Space Cadet
  29. shifts. If your shift keys are mod-taps, hold both shift mod-tap keys until
  30. the tapping term, then release them.
  31. * **Activate by double tapping Left Shift**: Add `#define
  32. DOUBLE_TAP_SHIFT_TURNS_ON_CAPS_WORD` config.h. Then, double tapping Left Shift
  33. turns on Caps Word. This method works with `KC_LSFT` or one-shot Left Shift
  34. `OSM(MOD_LSFT)`. To count as a double tap, the maximum time in milliseconds
  35. between taps is `TAPPING_TERM`, or if using `TAPPING_TERM_PER_KEY`, the time
  36. returned by `get_tapping_term()` for the shift keycode being tapped.
  37. * **Custom activation**: You can activate Caps Word from code by calling
  38. `caps_word_on()`. This may be used to activate Caps Word through [a
  39. combo](feature_combo.md) or [tap dance](feature_tap_dance.md) or any means
  40. you like.
  41. ### Troubleshooting: Command :id=troubleshooting-command
  42. When using `BOTH_SHIFTS_TURNS_ON_CAPS_WORD`, you might see a compile message
  43. **"BOTH_SHIFTS_TURNS_ON_CAPS_WORD and Command should not be enabled at the same
  44. time, since both use the Left Shift + Right Shift key combination."**
  45. Many keyboards enable the [Command feature](feature_command.md), which by
  46. default is also activated using the Left Shift + Right Shift key combination. To
  47. fix this conflict, please disable Command by adding in rules.mk:
  48. ```make
  49. COMMAND_ENABLE = no
  50. ```
  51. Or configure Command to use another key combination like Left Ctrl + Right Ctrl
  52. by defining `IS_COMMAND()` in config.h:
  53. ```c
  54. // Activate Command with Left Ctrl + Right Ctrl.
  55. #define IS_COMMAND() (get_mods() == MOD_MASK_CTRL)
  56. ```
  57. ## Customizing Caps Word :id=customizing-caps-word
  58. ### Idle timeout :id=idle-timeout
  59. Caps Word turns off automatically if no keys are pressed for
  60. `CAPS_WORD_IDLE_TIMEOUT` milliseconds. The default is 5000 (5 seconds).
  61. Configure the timeout duration in config.h, for instance
  62. ```c
  63. #define CAPS_WORD_IDLE_TIMEOUT 3000 // 3 seconds.
  64. ```
  65. Setting `CAPS_WORD_IDLE_TIMEOUT` to 0 configures Caps Word to never time out.
  66. Caps Word then remains active indefinitely until a word breaking key is pressed.
  67. ### Functions :id=functions
  68. Functions to manipulate Caps Word:
  69. | Function | Description |
  70. |-------------------------|------------------------------------------------|
  71. | `caps_word_on()` | Turns Caps Word on. |
  72. | `caps_word_off()` | Turns Caps Word off. |
  73. | `caps_word_toggle()` | Toggles Caps Word. |
  74. | `is_caps_word_on()` | Returns true if Caps Word is currently on. |
  75. ### Configure which keys are "word breaking" :id=configure-which-keys-are-word-breaking
  76. You can define the `caps_word_press_user(uint16_t keycode)` callback to
  77. configure which keys should be shifted and which keys are considered "word
  78. breaking" and stop Caps Word.
  79. The callback is called on every key press while Caps Word is active. When the
  80. key should be shifted (that is, a letter key), the callback should call
  81. `add_weak_mods(MOD_BIT(KC_LSFT))` to shift the key. Returning true continues the
  82. current "word," while returning false is "word breaking" and deactivates Caps
  83. Word. The default callback is
  84. ```c
  85. bool caps_word_press_user(uint16_t keycode) {
  86. switch (keycode) {
  87. // Keycodes that continue Caps Word, with shift applied.
  88. case KC_A ... KC_Z:
  89. case KC_MINS:
  90. add_weak_mods(MOD_BIT(KC_LSFT)); // Apply shift to next key.
  91. return true;
  92. // Keycodes that continue Caps Word, without shifting.
  93. case KC_1 ... KC_0:
  94. case KC_BSPC:
  95. case KC_DEL:
  96. case KC_UNDS:
  97. return true;
  98. default:
  99. return false; // Deactivate Caps Word.
  100. }
  101. }
  102. ```
  103. ### Representing Caps Word state :id=representing-caps-word-state
  104. Define `caps_word_set_user(bool active)` to get callbacks when Caps Word turns
  105. on or off. This is useful to represent the current Caps Word state, e.g. by
  106. setting an LED or playing a sound. In your keymap, define
  107. ```c
  108. void caps_word_set_user(bool active) {
  109. if (active) {
  110. // Do something when Caps Word activates.
  111. } else {
  112. // Do something when Caps Word deactivates.
  113. }
  114. }
  115. ```