aboutsummaryrefslogtreecommitdiff
path: root/docs/features
diff options
context:
space:
mode:
authorFilios92 <[email protected]>2024-09-06 08:27:20 +0200
committerGitHub <[email protected]>2024-09-05 23:27:20 -0700
commit0fd99096577a57453f070f2dd94baefa09e369a4 (patch)
tree23c3a69568b02530f18475c608c5d2297a9d680f /docs/features
parentb5c807fb4a365e59052f99c8d7c9e0ef7dc2ce86 (diff)
downloadqmk_firmware-0fd99096577a57453f070f2dd94baefa09e369a4.tar.gz
qmk_firmware-0fd99096577a57453f070f2dd94baefa09e369a4.zip
Add combo key repress feature (#22858)
Co-authored-by: jack <[email protected]>
Diffstat (limited to 'docs/features')
-rw-r--r--docs/features/combo.md44
1 files changed, 44 insertions, 0 deletions
diff --git a/docs/features/combo.md b/docs/features/combo.md
index bdb8c4b15f..10e33b72a6 100644
--- a/docs/features/combo.md
+++ b/docs/features/combo.md
@@ -307,6 +307,50 @@ bool process_combo_key_release(uint16_t combo_index, combo_t *combo, uint8_t key
return false;
}
```
+
+### Customizable key repress
+By defining `COMBO_PROCESS_KEY_REPRESS` and implementing `bool process_combo_key_repress(uint16_t combo_index, combo_t *combo, uint8_t key_index, uint16_t keycode)` you can run your custom code when you repress just released key of a combo. By combining it with custom `process_combo_event` we can for example make special handling for Alt+Tab to switch windows, which, on combo F+G activation, registers Alt and presses Tab - then we can switch windows forward by releasing G and pressing it again, or backwards with F key. Here's the full example:
+
+```c
+enum combos {
+ CMB_ALTTAB
+};
+
+const uint16_t PROGMEM combo_alttab[] = {KC_F, KC_G, COMBO_END};
+
+combo_t key_combos[COMBO_LENGTH] = {
+ [CMB_ALTTAB] = COMBO(combo_alttab, KC_NO), // KC_NO to leave processing for process_combo_event
+};
+
+void process_combo_event(uint16_t combo_index, bool pressed) {
+ switch (combo_index) {
+ case CMB_ALTTAB:
+ if (pressed) {
+ register_mods(MOD_LALT);
+ tap_code(KC_TAB);
+ } else {
+ unregister_mods(MOD_LALT);
+ }
+ break;
+ }
+}
+
+bool process_combo_key_repress(uint16_t combo_index, combo_t *combo, uint8_t key_index, uint16_t keycode) {
+ switch (combo_index) {
+ case CMB_ALTTAB:
+ switch (keycode) {
+ case KC_F:
+ tap_code16(S(KC_TAB));
+ return true;
+ case KC_G:
+ tap_code(KC_TAB);
+ return true;
+ }
+ }
+ return false;
+}
+```
+
### Layer independent combos
If you, for example, use multiple base layers for different key layouts, one for QWERTY, and another one for Colemak, you might want your combos to work from the same key positions on all layers. Defining the same combos again for another layout is redundant and takes more memory. The solution is to just check the keycodes from one layer.