aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 f4d128482..b69500f9c 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
61To 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. 61To 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.
62It can also be mitigated by increasing [`TAP_CODE_DELAY`](config_options.md#behaviors-that-can-be-configured). 62It can also be mitigated by increasing [`TAP_CODE_DELAY`](config_options.md#behaviors-that-can-be-configured).
63 63
64## Intercepting Mod-Taps
65
66### Changing tap function
67
68The 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`:
69
70```c
71bool process_record_user(uint16_t keycode, keyrecord_t *record) {
72 switch (keycode) {
73 case LCTL_T(KC_DQUO):
74 if (record->tap.count && record->event.pressed) {
75 tap_code16(KC_DQUO); // Send KC_DQUO on tap
76 return false; // Return false to ignore further processing of key
77 }
78 break;
79 }
80 return true;
81}
82```
83
84### Changing hold function
85
86Likewise, 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:
87
88```c
89bool process_record_user(uint16_t keycode, keyrecord_t *record) {
90 switch (keycode) {
91 case LT(0,KC_X):
92 if (record->tap.count && record->event.pressed) {
93 return true; // Return true for normal processing of tap keycode
94 } else if (record->event.pressed) {
95 tap_code16(C(KC_X)); // Intercept hold function to send Ctrl-X
96 }
97 return false;
98 case LT(0,KC_C):
99 if (record->tap.count && record->event.pressed) {
100 return true; // Return true for normal processing of tap keycode
101 } else if (record->event.pressed) {
102 tap_code16(C(KC_C)); // Intercept hold function to send Ctrl-C
103 }
104 return false;
105 case LT(0,KC_V):
106 if (record->tap.count && record->event.pressed) {
107 return true; // Return true for normal processing of tap keycode
108 } else if (record->event.pressed) {
109 tap_code16(C(KC_V)); // Intercept hold function to send Ctrl-V
110 }
111 return false;
112 }
113 return true;
114}
115```
116
117Enabling `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.
118
119### Changing both tap and hold
120
121This last example implements custom tap and hold function with `LT(0,KC_NO)` to create a single copy-on-tap, paste-on-hold key:
122
123```c
124bool process_record_user(uint16_t keycode, keyrecord_t *record) {
125 switch (keycode) {
126 case LT(0,KC_NO):
127 if (record->tap.count && record->event.pressed) {
128 tap_code16(C(KC_C)); // Intercept tap function to send Ctrl-C
129 } else if (record->event.pressed) {
130 tap_code16(C(KC_V)); // Intercept hold function to send Ctrl-V
131 }
132 return false;
133 }
134 return true;
135}
136```
137
64## Other Resources 138## Other Resources
65 139
66See the [Tap-Hold Configuration Options](tap_hold.md) for additional flags that tweak Mod-Tap behavior. 140See the [Tap-Hold Configuration Options](tap_hold.md) for additional flags that tweak Mod-Tap behavior.