summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQMK Bot <hello@qmk.fm>2021-10-04 23:21:33 +0000
committerQMK Bot <hello@qmk.fm>2021-10-04 23:21:33 +0000
commit2d71d14191ccfd876aca07ca86643e606e6e0957 (patch)
tree68a9d65dd1ea4c91da011e949bca322a56f7695e
parent4af4ef3428d8ca39bcd3a29d2bebdf84ebe417ec (diff)
parent27d9579fd52b56dd4aa65e14a604ae4eb51386f3 (diff)
Merge remote-tracking branch 'origin/master' into develop
-rw-r--r--docs/mod_tap.md74
1 files changed, 74 insertions, 0 deletions
diff --git a/docs/mod_tap.md b/docs/mod_tap.md
index f4d128482b..b69500f9c9 100644
--- a/docs/mod_tap.md
+++ b/docs/mod_tap.md
@@ -61,6 +61,80 @@ You may also run into issues when using Remote Desktop Connection on Windows. Be
To fix this, open Remote Desktop Connection, click on "Show Options", open the the "Local Resources" tab, and in the keyboard section, change the drop down to "On this Computer". This will fix the issue, and allow the characters to work correctly.
It can also be mitigated by increasing [`TAP_CODE_DELAY`](config_options.md#behaviors-that-can-be-configured).
+## Intercepting Mod-Taps
+
+### Changing tap function
+
+The basic keycode limitation with Mod-Tap can be worked around by intercepting it in `process_record_user`. For example, shifted keycode `KC_DQUO` cannot be used with `MT()` because it is a 16-bit keycode alias of `LSFT(KC_QUOT)`. Modifiers on `KC_DQUO` will be masked by `MT()`. But the following custom code can be used to intercept the "tap" function to manually send `KC_DQUO`:
+
+```c
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+ switch (keycode) {
+ case LCTL_T(KC_DQUO):
+ if (record->tap.count && record->event.pressed) {
+ tap_code16(KC_DQUO); // Send KC_DQUO on tap
+ return false; // Return false to ignore further processing of key
+ }
+ break;
+ }
+ return true;
+}
+```
+
+### Changing hold function
+
+Likewise, the same custom code can also be used to intercept the hold function to send custom user key code. The following example uses `LT(0, kc)` (layer-tap key with no practical use because layer 0 is always active) to add cut, copy and paste function to X,C and V keys when they are held down:
+
+```c
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+ switch (keycode) {
+ case LT(0,KC_X):
+ if (record->tap.count && record->event.pressed) {
+ return true; // Return true for normal processing of tap keycode
+ } else if (record->event.pressed) {
+ tap_code16(C(KC_X)); // Intercept hold function to send Ctrl-X
+ }
+ return false;
+ case LT(0,KC_C):
+ if (record->tap.count && record->event.pressed) {
+ return true; // Return true for normal processing of tap keycode
+ } else if (record->event.pressed) {
+ tap_code16(C(KC_C)); // Intercept hold function to send Ctrl-C
+ }
+ return false;
+ case LT(0,KC_V):
+ if (record->tap.count && record->event.pressed) {
+ return true; // Return true for normal processing of tap keycode
+ } else if (record->event.pressed) {
+ tap_code16(C(KC_V)); // Intercept hold function to send Ctrl-V
+ }
+ return false;
+ }
+ return true;
+}
+```
+
+Enabling `IGNORE_MOD_TAP_INTERRUPT` is recommended when using Mod-Tap on alphanumeric keys to avoid hold function taking precendence when the next key is pressed quickly. See [Ignore Mod Tap Interrupt](tap_hold.md#ignore-mod-tap-interrupt) for more details.
+
+### Changing both tap and hold
+
+This last example implements custom tap and hold function with `LT(0,KC_NO)` to create a single copy-on-tap, paste-on-hold key:
+
+```c
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+ switch (keycode) {
+ case LT(0,KC_NO):
+ if (record->tap.count && record->event.pressed) {
+ tap_code16(C(KC_C)); // Intercept tap function to send Ctrl-C
+ } else if (record->event.pressed) {
+ tap_code16(C(KC_V)); // Intercept hold function to send Ctrl-V
+ }
+ return false;
+ }
+ return true;
+}
+```
+
## Other Resources
See the [Tap-Hold Configuration Options](tap_hold.md) for additional flags that tweak Mod-Tap behavior.