-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
40b4401
commit 610f357
Showing
4 changed files
with
138 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
--- | ||
title: Array of Behaviors | ||
sidebar_label: Array | ||
--- | ||
|
||
## Summary | ||
|
||
An array of behaviors is meant not to be placed in your keymap directly, but rather to simplify the usage of other behaviors such as [hold-tap](hold-tap.mdx), [combo-trigger](combo-trigger.md), or [mod-morph](mod-morph.md). | ||
|
||
Invoking an array of behaviors with a particular integer will trigger the behavior at that location in the array (indexed from 0). | ||
|
||
## Mod-Morph | ||
|
||
### Configuration | ||
|
||
Below is an example of how to implement an array with three elements. | ||
|
||
```dts | ||
/ { | ||
arr: behavior_array { | ||
compatible = "zmk,behavior-array"; | ||
#binding-cells = <1>; | ||
bindings = <&mt LEFT_CONTROL A &kp B < 1 C>; | ||
}; | ||
}; | ||
``` | ||
|
||
The above behavior array could be triggered like so: | ||
|
||
```dts | ||
&arr 0 | ||
``` | ||
|
||
The above would act like `&mt LEFT_CONTROL A`. | ||
|
||
```dts | ||
&arr 1 | ||
``` | ||
|
||
The above would act like `&kp B`. | ||
|
||
```dts | ||
&arr 2 | ||
``` | ||
|
||
The above would act like `< 1 C`. | ||
|
||
The `&arr X` call could happen in your keymap, but it is more useful if it is used e.g. as the `fallback-behavior` parameter of a [combo-trigger](combo-trigger.md): | ||
|
||
```dts | ||
/ { | ||
behaviors { | ||
combo_mt: combo_trigger_or_key_press { | ||
compatible = "zmk,behavior-combo-trigger"; | ||
#binding-cells = <2>; | ||
display-name = "Combo or Mod Tap"; | ||
fallback-behavior = <&mt_arr>; | ||
}; | ||
mt_arr: mod_tap_behavior_array { | ||
compatible = "zmk,behavior-array"; | ||
#binding-cells = <1>; | ||
bindings = <&mt LEFT_CONTROL A &mt LEFT_CONTROL B &mt LEFT_CONTROL C>; | ||
}; | ||
}; | ||
}; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
title: Combo Trigger Behavior | ||
sidebar_label: Combo Trigger | ||
--- | ||
|
||
## Summary | ||
|
||
The combo trigger behavior is a special type of behavior that is used together with the [`compatible = "zmk,combos";`](../combos.md) node to add combos to your keymap. | ||
|
||
## Combo Trigger | ||
|
||
### Configuration | ||
|
||
Below is an example of how to implement the combo trigger "Combo or Key Press". When assigned to a key, it will send the combo trigger id of the first parameter passed to it on to the `combos` node. If no combo is triggered, the fallback behavior is triggered using the second parameter passed to the combo trigger. | ||
|
||
```dts | ||
/ { | ||
behaviors { | ||
combo_kp: combo_trigger_or_key_press { | ||
compatible = "zmk,behavior-combo-trigger"; | ||
#binding-cells = <2>; | ||
display-name = "Combo or Key Press"; | ||
fallback-behavior = <&kp>; | ||
}; | ||
}; | ||
}; | ||
``` | ||
|
||
Note that this specific combo trigger behavior exists in ZMK by default using the binding `&combo_kp`. | ||
|
||
### Behavior Binding | ||
|
||
- Reference: `&combo_kp` | ||
- Parameter: None | ||
|
||
Example: | ||
|
||
```dts | ||
&combo_kp 1 A | ||
``` | ||
|
||
When activated, the `combos` node receives the trigger `1`. If no combo is triggered, the activation acts like a `&kp A` instead. | ||
|
||
### Fallback Behavior | ||
|
||
It is assumed that the behavior in `fallback-behavior` accepts a single parameter as an argument. Hence the behavior should always be given without any arguments. If the behavior accepts no arguments, two parameters should still be passed to the combo trigger: | ||
|
||
```dts | ||
&combo_no_param_fallback 1 0 | ||
``` | ||
|
||
If the behavior you wish to have as a fallback-behavior accepts two parameters as arguments, it is recommended that you make use of the [array behavior](array.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters