fix(docs): Update tap-dance and hold-tap documentation

- Replace raster timing diagrams with vector assets
- Improve conciseness of tap-dance docs by adding tabs for example implementation
- Expand upon tap-dance bindings and the effect of binding index on the number of keypresses required to output the bindng

Co-Authored-By: Cem Aksoylar <caksoylar@users.noreply.github.com>
This commit is contained in:
Kurtis Lew 2022-05-12 19:41:25 -07:00
parent f68692effd
commit c3d7dc4866
9 changed files with 407 additions and 107 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 155 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 866 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 89 KiB

After

Width:  |  Height:  |  Size: 145 KiB

View file

@ -13,11 +13,11 @@ Simply put, the hold-tap key will output the 'hold' behavior if it's held for a
The graph below shows how the hold-tap decides between a 'tap' and a 'hold'.
![Simple behavior](../assets/hold-tap/case1_2.png)
![Simple behavior](../assets/hold-tap/case1_2.svg)
By default, the hold-tap is configured to also select the 'hold' functionality if another key is tapped while it's active:
![Hold preferred behavior](../assets/hold-tap/case1_2.png)
![Hold preferred behavior](../assets/hold-tap/case_hold_preferred.svg)
We call this the 'hold-preferred' flavor of hold-taps. While this flavor may work very well for a ctrl/escape key, it's not very well suited for home-row mods or layer-taps. That's why there are two more flavors to choose from: 'tap-preferred' and 'balanced'.
@ -30,7 +30,7 @@ We call this the 'hold-preferred' flavor of hold-taps. While this flavor may wor
When the hold-tap key is released and the hold behavior has not been triggered, the tap behavior will trigger.
![Hold-tap comparison](../assets/hold-tap/comparison.png)
![Hold-tap comparison](../assets/hold-tap/comparison.svg)
### Basic usage

View file

@ -3,39 +3,39 @@ title: Tap-Dance Behavior
sidebar_label: Tap-Dance
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
## Summary
A tap-dance key invokes a different behavior (e.g. `kp`) corresponding
to how many times it is pressed. For example, you could configure a
tap-dance key that acts as `LSHIFT` if tapped once, or Caps _Lock_ if tapped twice.
The expandability of the number of [`bindings`](#bindings) attached to a
particular tap-dance is a great way to add more functionality to a single key,
especially for keyboards with a limited number of keys.
Tap-dances are completely custom, so for every unique tap-dance key,
a new tap-dance must be defined in your keymap's `behaviors`.
A tap-dance key invokes a different behavior (e.g. `kp`) corresponding to how many times it is pressed. For example, you could configure a tap-dance key that acts as `LSHIFT` if tapped once, or Caps _Lock_ if tapped twice. The expandability of the number of [`bindings`](#bindings) attached to a particular tap-dance is a great way to add more functionality to a single key, especially for keyboards with a limited number of keys. Tap-dances are completely custom, so for every unique tap-dance key,a new tap-dance must be defined in your keymap's `behaviors`.
Tap-dances are designed to resolve immediately when interrupted by another keypress.
Meaning, when a keybind is pressed other than any active tap-dances,
the tap-dance will activate according to the current value of its
counter before the interrupting keybind is registered.
Tap-dances are designed to resolve immediately when interrupted by another keypress. Meaning, when a keybind is pressed other than any active tap-dances, the tap-dance will activate according to the current value of its counter before the interrupting keybind is registered.
### Configuration
#### `tapping-term-ms`
Defines the maximum elapsed time after the last tap-dance keybind press
before a binding is selected from [`bindings`](#bindings).
Default value is `200`ms.
Defines the maximum elapsed time after the last tap-dance keybind press before a binding is selected from [`bindings`](#bindings). Default value is `200`ms.
#### `bindings`
An array of one or more keybinds. This list can include [any ZMK keycode](../codes/) and bindings for ZMK behaviors.
An array of one or more keybinds. This list can include [any ZMK keycode](../codes/) and any listed ZMK behavior, like [hold-taps](hold-tap.md), or [sticky keys](sticky-key.md). The index of a keybind in the `bindings` array corresponds to the number of times the tap-dance binding is pressed. For example, in the [basic tap-dance counter](#basic-example-counter) shown below, `&kp N2` is the second binding in the array of `bindings`: we then see an output of `2` when the `td0` binding is pressed twice.
#### Example Usage
### Example Usage
This example configures a tap-dance named `td0` that outputs the number of times it is pressed from 1-3.
<Tabs
defaultValue="basic"
values={[
{label: 'Basic Example: Counter', value: 'basic'},
{label: 'Advanced Example: Mod-Tap Nested inside Tap-Dance', value: 'advanced'},
]}>
```
<TabItem value="basic">
This example configures a tap-dance named `td0` that outputs the number of times its binding is pressed from 1-3.
```title="Basic Tap-Dance Example: Counter"
#include <behaviors.dtsi>
#include <dt-bindings/zmk/keys.h>
@ -67,10 +67,41 @@ The following image describes the behavior of this particular tap-dance.
![Timing Diagram](../assets/tap-dance/timing_diagram.svg)
:::note
Alphanumeric [`key press`](key-press.md) bindings, like those used for `td0`,
will release as soon as an interrupting key press occurs.
For instance, if a modifier key like `LSHIFT` were to replace the `N1`
binding in the last example above, it would remain pressed until `td0`'s
binding is released and the output would instead be `J`. Any following
alphanumeric key presses would be capitalized as long as `td0` is held down.
Alphanumeric [`key press`](key-press.md) bindings, like those used for `td0`, will release as soon as an interrupting key press occurs. For instance, if a modifier key like `LSHIFT` were to replace the `N1` binding in the last example above, it would remain pressed until `td0`'s binding is released and the output would instead be `J`. Any following alphanumeric key presses would be capitalized as long as `td0` is held down.
:::
</TabItem>
<TabItem value="advanced">
This example configures a mod-tap inside a tap-dance named `td_mt` that outputs `LSHIFT` on a single tap, `CAPSLOCK` on a single press and hold, and `LCTRL` on double-tap.
```title="Advanced Tap-Dance Example: Nested Mod-Tap"
#include <behaviors.dtsi>
#include <dt-bindings/zmk/keys.h>
/ {
behaviors {
td_mt: tap_dance_mod_tap {
compatible = "zmk,behavior-tap-dance";
label = "TAP_DANCE_MOD_TAP";
#binding-cells = <0>;
tapping-term-ms = <200>;
bindings = <&mt CAPSLOCK LSHIFT>, <&kp LCTRL>;
};
};
keymap {
compatible = "zmk,keymap";
default_layer {
bindings = <
&td_mt
>;
};
};
};
```
</TabItem>
</Tabs>