summaryrefslogtreecommitdiff
path: root/docs/tap_hold.md
diff options
context:
space:
mode:
authorWJH <hou32hou@gmail.com>2022-03-11 04:48:33 +0800
committerGitHub <noreply@github.com>2022-03-10 12:48:33 -0800
commit6c40b6856bb843e39bf0992164f41e29ce7ea72c (patch)
treea896e271e89db8d73b869624695bbf660a533861 /docs/tap_hold.md
parentb33fdc299c7ae702582969ef66d73fcc5806bcbb (diff)
[Docs] Include ASCII diagram to explain tap-hold modes (#15873)
* [Docs] Include ASCII diagram to explain tap-hold modes * [Docs]: add examples for Default mode for Tap Hold * [Docs] fix some wrong explanation in tap_hold.md
Diffstat (limited to 'docs/tap_hold.md')
-rw-r--r--docs/tap_hold.md115
1 files changed, 115 insertions, 0 deletions
diff --git a/docs/tap_hold.md b/docs/tap_hold.md
index d206c10cc5..39fa84a9f3 100644
--- a/docs/tap_hold.md
+++ b/docs/tap_hold.md
@@ -126,6 +126,61 @@ The code which decides between the tap and hold actions of dual-role keys suppor
126 126
127Note that until the tap-or-hold decision completes (which happens when either the dual-role key is released, or the tapping term has expired, or the extra condition for the selected decision mode is satisfied), key events are delayed and not transmitted to the host immediately. The default mode gives the most delay (if the dual-role key is held down, this mode always waits for the whole tapping term), and the other modes may give less delay when other keys are pressed, because the hold action may be selected earlier. 127Note that until the tap-or-hold decision completes (which happens when either the dual-role key is released, or the tapping term has expired, or the extra condition for the selected decision mode is satisfied), key events are delayed and not transmitted to the host immediately. The default mode gives the most delay (if the dual-role key is held down, this mode always waits for the whole tapping term), and the other modes may give less delay when other keys are pressed, because the hold action may be selected earlier.
128 128
129### Default Mode
130Example sequence 1 (the `L` key is also mapped to `KC_RGHT` on layer 2):
131
132```
133 TAPPING_TERM
134 +---------------|--------------------+
135 | +-------------|-------+ |
136 | | LT(2, KC_A) | | |
137 | +-------------|-------+ |
138 | | +--------------+ |
139 | | | KC_L | |
140 | | +--------------+ |
141 +---------------|--------------------+
142```
143The above sequence would send a `KC_RGHT`, since `LT(2, KC_A)` is held longer than the `TAPPING_TERM`.
144
145---
146
147Example sequence 2 (the `L` key is also mapped to `KC_RGHT` on layer 2):
148
149```
150 TAPPING_TERM
151 +-----------------------------|------+
152 | +---------------+ | |
153 | | LT(2, KC_A) | | |
154 | +---------------+ | |
155 | +--------------+ | |
156 | | KC_L | | |
157 | +--------------+ | |
158 +-----------------------------|------+
159```
160The above sequence will not send `KC_RGHT` but `KC_A` `KC_L` instead, since `LT(2, KC_A)` is not held longer than the `TAPPING_TERM`.
161
162---
163
164Example sequence 3 (Mod Tap):
165
166```
167 TAPPING_TERM
168 +---------------------------|--------+
169 | +-------------+ | |
170 | | SFT_T(KC_A) | | |
171 | +-------------+ | |
172 | +--------------+ | |
173 | | KC_X | | |
174 | +--------------+ | |
175 +---------------------------|--------+
176```
177Based previous examples, you might have expected the output of the above sequence to be `KC_A` `KC_X`
178since `SFT_T(KC_A)` is NOT held longer than the `TAPPING_TERM`.
179However, the actual output would be capital `X` (`SHIFT` + `x`) due to reasons
180explained under [Ignore Mod Tap Interrupt](#ignore-mod-tap-interrupt).
181
182
183
129### Permissive Hold 184### Permissive Hold
130 185
131The “permissive hold” mode can be enabled for all dual-role keys by adding the corresponding option to `config.h`: 186The “permissive hold” mode can be enabled for all dual-role keys by adding the corresponding option to `config.h`:
@@ -145,6 +200,18 @@ An example of a sequence which is affected by the “permissive hold” mode:
145- `KC_L` Up 200- `KC_L` Up
146- `LT(2, KC_A)` Up 201- `LT(2, KC_A)` Up
147 202
203```
204 TAPPING_TERM
205 +---------------------------|--------+
206 | +----------------------+ | |
207 | | LT(2, KC_A) | | |
208 | +----------------------+ | |
209 | +--------------+ | |
210 | | KC_L | | |
211 | +--------------+ | |
212 +---------------------------|--------+
213```
214
148Normally, if you do all this within the `TAPPING_TERM` (default: 200ms), this will be registered as `al` by the firmware and host system. With the `PERMISSIVE_HOLD` option enabled, the Layer Tap key is considered as a layer switch if another key is tapped, and the above sequence would be registered as `KC_RGHT` (the mapping of `L` on layer 2). We could describe this sequence as a “nested press” (the modified key's key down and key up events are “nested” between the dual-role key's key down and key up events). 215Normally, if you do all this within the `TAPPING_TERM` (default: 200ms), this will be registered as `al` by the firmware and host system. With the `PERMISSIVE_HOLD` option enabled, the Layer Tap key is considered as a layer switch if another key is tapped, and the above sequence would be registered as `KC_RGHT` (the mapping of `L` on layer 2). We could describe this sequence as a “nested press” (the modified key's key down and key up events are “nested” between the dual-role key's key down and key up events).
149 216
150However, this slightly different sequence will not be affected by the “permissive hold” mode: 217However, this slightly different sequence will not be affected by the “permissive hold” mode:
@@ -154,6 +221,18 @@ However, this slightly different sequence will not be affected by the “permiss
154- `LT(2, KC_A)` Up 221- `LT(2, KC_A)` Up
155- `KC_L` Up 222- `KC_L` Up
156 223
224```
225 TAPPING_TERM
226 +---------------------------|--------+
227 | +-------------+ | |
228 | | LT(2, KC_A) | | |
229 | +-------------+ | |
230 | +--------------+ | |
231 | | KC_L | | |
232 | +--------------+ | |
233 +---------------------------|--------+
234```
235
157In the sequence above the dual-role key is released before the other key is released, and if that happens within the tapping term, the “permissive hold” mode will still choose the tap action for the dual-role key, and the sequence will be registered as `al` by the host. We could describe this as a “rolling press” (the two keys' key down and key up events behave as if you were rolling a ball across the two keys, first pressing each key down in sequence and then releasing them in the same order). 236In the sequence above the dual-role key is released before the other key is released, and if that happens within the tapping term, the “permissive hold” mode will still choose the tap action for the dual-role key, and the sequence will be registered as `al` by the host. We could describe this as a “rolling press” (the two keys' key down and key up events behave as if you were rolling a ball across the two keys, first pressing each key down in sequence and then releasing them in the same order).
158 237
159?> The `PERMISSIVE_HOLD` option also affects Mod Tap keys, but this may not be noticeable if you do not also enable the `IGNORE_MOD_TAP_INTERRUPT` option for those keys, because the default handler for Mod Tap keys also considers both the “nested press” and “rolling press” sequences like shown above as a modifier hold, not the tap action. If you do not enable `IGNORE_MOD_TAP_INTERRUPT`, the effect of `PERMISSIVE_HOLD` on Mod Tap keys would be limited to reducing the delay before the key events are made visible to the host. 238?> The `PERMISSIVE_HOLD` option also affects Mod Tap keys, but this may not be noticeable if you do not also enable the `IGNORE_MOD_TAP_INTERRUPT` option for those keys, because the default handler for Mod Tap keys also considers both the “nested press” and “rolling press” sequences like shown above as a modifier hold, not the tap action. If you do not enable `IGNORE_MOD_TAP_INTERRUPT`, the effect of `PERMISSIVE_HOLD` on Mod Tap keys would be limited to reducing the delay before the key events are made visible to the host.
@@ -198,6 +277,18 @@ An example of a sequence which is affected by the “hold on other key press”
198- `LT(2, KC_A)` Up 277- `LT(2, KC_A)` Up
199- `KC_L` Up 278- `KC_L` Up
200 279
280```
281 TAPPING_TERM
282 +---------------------------|--------+
283 | +-------------+ | |
284 | | LT(2, KC_A) | | |
285 | +-------------+ | |
286 | +--------------+ | |
287 | | KC_L | | |
288 | +--------------+ | |
289 +---------------------------|--------+
290```
291
201Normally, if you do all this within the `TAPPING_TERM` (default: 200ms), this will be registered as `al` by the firmware and host system. With the `HOLD_ON_OTHER_KEY_PRESS` option enabled, the Layer Tap key is considered as a layer switch if another key is pressed, and the above sequence would be registered as `KC_RGHT` (the mapping of `L` on layer 2). 292Normally, if you do all this within the `TAPPING_TERM` (default: 200ms), this will be registered as `al` by the firmware and host system. With the `HOLD_ON_OTHER_KEY_PRESS` option enabled, the Layer Tap key is considered as a layer switch if another key is pressed, and the above sequence would be registered as `KC_RGHT` (the mapping of `L` on layer 2).
202 293
203?> The `HOLD_ON_OTHER_KEY_PRESS` option also affects Mod Tap keys, but this may not be noticeable if you do not also enable the `IGNORE_MOD_TAP_INTERRUPT` option for those keys, because the default handler for Mod Tap keys also considers the “rolling press” sequence like shown above as a modifier hold, not the tap action. If you do not enable `IGNORE_MOD_TAP_INTERRUPT`, the effect of `HOLD_ON_OTHER_KEY_PRESS` on Mod Tap keys would be limited to reducing the delay before the key events are made visible to the host. 294?> The `HOLD_ON_OTHER_KEY_PRESS` option also affects Mod Tap keys, but this may not be noticeable if you do not also enable the `IGNORE_MOD_TAP_INTERRUPT` option for those keys, because the default handler for Mod Tap keys also considers the “rolling press” sequence like shown above as a modifier hold, not the tap action. If you do not enable `IGNORE_MOD_TAP_INTERRUPT`, the effect of `HOLD_ON_OTHER_KEY_PRESS` on Mod Tap keys would be limited to reducing the delay before the key events are made visible to the host.
@@ -245,6 +336,18 @@ An example of a sequence which will be affected by the `IGNORE_MOD_TAP_INTERRUPT
245- `SFT_T(KC_A)` Up 336- `SFT_T(KC_A)` Up
246- `KC_X` Up 337- `KC_X` Up
247 338
339```
340 TAPPING_TERM
341 +---------------------------|--------+
342 | +-------------+ | |
343 | | SFT_T(KC_A) | | |
344 | +-------------+ | |
345 | +--------------+ | |
346 | | KC_X | | |
347 | +--------------+ | |
348 +---------------------------|--------+
349```
350
248Normally, this would send a capital `X` (`SHIFT`+`x`), even if the sequence is performed faster than the `TAPPING_TERM`. However, if the `IGNORE_MOD_TAP_INTERRUPT` option is enabled, the `SFT_T(KC_A)` key must be held longer than the `TAPPING_TERM` to register the hold action. A quick tap will output `ax` in this case, while a hold will still output a capital `X` (`SHIFT`+`x`). 351Normally, this would send a capital `X` (`SHIFT`+`x`), even if the sequence is performed faster than the `TAPPING_TERM`. However, if the `IGNORE_MOD_TAP_INTERRUPT` option is enabled, the `SFT_T(KC_A)` key must be held longer than the `TAPPING_TERM` to register the hold action. A quick tap will output `ax` in this case, while a hold will still output a capital `X` (`SHIFT`+`x`).
249 352
250However, if the `HOLD_ON_OTHER_KEY_PRESS` option is enabled in addition to `IGNORE_MOD_TAP_INTERRUPT`, the above sequence will again send a capital `X` (`SHIFT`+`x`) even if performed faster that the `TAPPING_TERM`. The difference from the default configuration is that by default the host will receive the key events only after the `SFT_T(KC_A)` key is released, but with the `HOLD_ON_OTHER_KEY_PRESS` option the host will start receiving key events when the `KC_X` key is pressed. 353However, if the `HOLD_ON_OTHER_KEY_PRESS` option is enabled in addition to `IGNORE_MOD_TAP_INTERRUPT`, the above sequence will again send a capital `X` (`SHIFT`+`x`) even if performed faster that the `TAPPING_TERM`. The difference from the default configuration is that by default the host will receive the key events only after the `SFT_T(KC_A)` key is released, but with the `HOLD_ON_OTHER_KEY_PRESS` option the host will start receiving key events when the `KC_X` key is pressed.
@@ -327,6 +430,18 @@ Holding and releasing a dual function key without pressing another key will resu
327 430
328For instance, holding and releasing `LT(2, KC_SPC)` without hitting another key will result in nothing happening. With this enabled, it will send `KC_SPC` instead. 431For instance, holding and releasing `LT(2, KC_SPC)` without hitting another key will result in nothing happening. With this enabled, it will send `KC_SPC` instead.
329 432
433```
434 TAPPING_TERM
435 +-----------------|------------------+
436 | +---------------|-------+ |
437 | | LT(2, KC_SPC) | | |
438 | +---------------|-------+ |
439 | | |
440 | | |
441 | | |
442 +-----------------|------------------+
443```
444
330For more granular control of this feature, you can add the following to your `config.h`: 445For more granular control of this feature, you can add the following to your `config.h`:
331 446
332```c 447```c