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

Caps Word

It is often useful to type a single word in all capitals, for instance abbreviations like "QMK", or in code, identifiers like KC_SPC. "Caps Word" is a modern alternative to Caps Lock:

How do I enable Caps Word

In your rules.mk, add:

make
CAPS_WORD_ENABLE = yes

Next, use one the following methods to activate Caps Word:

Troubleshooting: Command

When using BOTH_SHIFTS_TURNS_ON_CAPS_WORD, you might see a compile message "BOTH_SHIFTS_TURNS_ON_CAPS_WORD and Command should not be enabled at the same time, since both use the Left Shift + Right Shift key combination."

Many keyboards enable the Command feature, which by default is also activated using the Left Shift + Right Shift key combination. To fix this conflict, please disable Command by adding in rules.mk:

make
COMMAND_ENABLE = no

Or configure Command to use another key combination like Left Ctrl + Right Ctrl by defining IS_COMMAND() in config.h:

c
// Activate Command with Left Ctrl + Right Ctrl.\n#define IS_COMMAND() (get_mods() == MOD_MASK_CTRL)

Customizing Caps Word

Invert on shift

By default, Caps Word turns off when Shift keys are pressed, considering them as word-breaking. Alternatively with the CAPS_WORD_INVERT_ON_SHIFT option, pressing the Shift key continues Caps Word and inverts the shift state. This is convenient for uncapitalizing one or a few letters within a word, for example with Caps Word on, typing "D, B, Shift+A, Shift+A, S" produces "DBaaS", or typing "P, D, F, Shift+S" produces "PDFs".

Enable it by adding in config.h

c
#define CAPS_WORD_INVERT_ON_SHIFT

This option works with regular Shift keys KC_LSFT and KC_RSFT, mod-tap Shift keys, and one-shot Shift keys. Note that while Caps Word is on, one-shot Shift keys behave like regular Shift keys, and have effect only while they are held.

Idle timeout

Caps Word turns off automatically if no keys are pressed for CAPS_WORD_IDLE_TIMEOUT milliseconds. The default is 5000 (5 seconds). Configure the timeout duration in config.h, for instance

c
#define CAPS_WORD_IDLE_TIMEOUT 3000  // 3 seconds.

Setting CAPS_WORD_IDLE_TIMEOUT to 0 configures Caps Word to never time out. Caps Word then remains active indefinitely until a word breaking key is pressed.

Functions

Functions to manipulate Caps Word:

FunctionDescription
caps_word_on()Turns Caps Word on.
caps_word_off()Turns Caps Word off.
caps_word_toggle()Toggles Caps Word.
is_caps_word_on()Returns true if Caps Word is currently on.

Configure which keys are "word breaking"

You can define the caps_word_press_user(uint16_t keycode) callback to configure which keys should be shifted and which keys are considered "word breaking" and stop Caps Word.

The callback is called on every key press while Caps Word is active. When the key should be shifted (that is, a letter key), the callback should call add_weak_mods(MOD_BIT(KC_LSFT)) to shift the key. Returning true continues the current "word," while returning false is "word breaking" and deactivates Caps Word. The default callback is

c
bool caps_word_press_user(uint16_t keycode) {\n    switch (keycode) {\n        // Keycodes that continue Caps Word, with shift applied.\n        case KC_A ... KC_Z:\n        case KC_MINS:\n            add_weak_mods(MOD_BIT(KC_LSFT));  // Apply shift to next key.\n            return true;\n\n        // Keycodes that continue Caps Word, without shifting.\n        case KC_1 ... KC_0:\n        case KC_BSPC:\n        case KC_DEL:\n        case KC_UNDS:\n            return true;\n\n        default:\n            return false;  // Deactivate Caps Word.\n    }\n}

Representing Caps Word state

Define caps_word_set_user(bool active) to get callbacks when Caps Word turns on or off. This is useful to represent the current Caps Word state, e.g. by setting an LED or playing a sound. In your keymap, define

c
void caps_word_set_user(bool active) {\n    if (active) {\n        // Do something when Caps Word activates.\n    } else {\n        // Do something when Caps Word deactivates.\n    }\n}
', 34); const _hoisted_35 = [ _hoisted_1 ]; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return openBlock(), createElementBlock("div", null, _hoisted_35); } const caps_word = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]); export { __pageData, caps_word as default };