fix verbiage and docs
This commit is contained in:
parent
55ee10ce1d
commit
c239ab1353
5 changed files with 54 additions and 76 deletions
|
@ -39,8 +39,8 @@
|
|||
#binding-cells = <0>;
|
||||
bindings = <&kp CAPSLOCK>;
|
||||
enable-on-press;
|
||||
disable-on-second-press;
|
||||
disable-on-keys = <SPACE TAB ENTER ESCAPE>;
|
||||
disable-on-next-release;
|
||||
disable-on-keys = <SPACE TAB ENTER>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -12,7 +12,7 @@ properties:
|
|||
type: boolean
|
||||
disable-on-release:
|
||||
type: boolean
|
||||
disable-on-second-press:
|
||||
disable-on-next-release:
|
||||
type: boolean
|
||||
disable-on-keys:
|
||||
type: array
|
||||
|
|
|
@ -35,7 +35,7 @@ struct behavior_capslock_config {
|
|||
struct zmk_behavior_binding capslock_binding;
|
||||
bool enable_on_press;
|
||||
bool disable_on_release;
|
||||
bool disable_on_second_press;
|
||||
bool disable_on_next_release;
|
||||
uint8_t disable_on_keys_count;
|
||||
struct capslock_key_item disable_on_keys[];
|
||||
};
|
||||
|
@ -104,7 +104,7 @@ static int on_capslock_binding_released(struct zmk_behavior_binding *binding,
|
|||
const struct behavior_capslock_config *config = dev->config;
|
||||
struct behavior_capslock_data *data = dev->data;
|
||||
|
||||
if (config->disable_on_release || (config->disable_on_second_press && !data->just_activated)) {
|
||||
if (config->disable_on_release || (config->disable_on_next_release && !data->just_activated)) {
|
||||
deactivate_capslock(dev);
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ static int behavior_capslock_init(const struct device *dev) {
|
|||
.capslock_binding = _TRANSFORM_ENTRY(0, n), \
|
||||
.enable_on_press = DT_INST_PROP(n, enable_on_press), \
|
||||
.disable_on_release = DT_INST_PROP(n, disable_on_release), \
|
||||
.disable_on_second_press = DT_INST_PROP(n, disable_on_second_press), \
|
||||
.disable_on_next_release = DT_INST_PROP(n, disable_on_next_release), \
|
||||
.disable_on_keys = {UTIL_LISTIFY(DT_INST_PROP_LEN(n, disable_on_keys), BREAK_ITEM, n)}, \
|
||||
.disable_on_keys_count = DT_INST_PROP_LEN(n, disable_on_keys), \
|
||||
}; \
|
||||
|
|
20
docs/docs/behaviors/caps-word.md
Normal file
20
docs/docs/behaviors/caps-word.md
Normal file
|
@ -0,0 +1,20 @@
|
|||
---
|
||||
title: Caps Word Behavior
|
||||
sidebar_label: Caps Word
|
||||
---
|
||||
|
||||
## Summary
|
||||
|
||||
The caps word behavior behaves similar to a caps lock, but will automatically deactivate when any key in a word separator list is pressed, or if the caps word key is pressed again.
|
||||
|
||||
### Behavior Binding
|
||||
|
||||
- Reference: `&caps_word`
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
&caps_word
|
||||
```
|
||||
|
||||
See [caps lock](/docs/behaviors/capslock)
|
|
@ -5,96 +5,54 @@ sidebar_label: Caps Lock
|
|||
|
||||
## Summary
|
||||
|
||||
This set of behaviors offers enhahced versions of the caps lock key.
|
||||
|
||||
|
||||
## Caps On
|
||||
|
||||
Enables caps lock when pressed, regarless of the current caps lock state.
|
||||
The caps lock behavior provides an improved caps lock key.
|
||||
Pressing the regular caps lock key toggles the state of caps lock on the host machine, this behavior offers more control on how and when caps lock get activated and deactivated, regardless of the current status on the host machine.
|
||||
|
||||
### Behavior Binding
|
||||
- Reference: `&caps_on`
|
||||
|
||||
Example:
|
||||
Four pre-configured instances are provided:
|
||||
|
||||
```
|
||||
&caps_on
|
||||
```
|
||||
|
||||
|
||||
## Caps Off
|
||||
|
||||
Disables caps lock when released, regarless of the current caps lock state.
|
||||
|
||||
### Behavior Binding
|
||||
- Reference: `&caps_off`
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
&caps_off
|
||||
```
|
||||
|
||||
|
||||
## Caps Hold
|
||||
|
||||
Enables caps lock when pressed, and disables it when released.
|
||||
|
||||
### Behavior Binding
|
||||
- Reference: `&caps_hold`
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
&caps_hold
|
||||
```
|
||||
|
||||
|
||||
## Caps Word
|
||||
|
||||
Enables caps lock when pressed, and deactivate it when any key in the break list is pressed, or if the caps word key is pressed again.
|
||||
|
||||
### Behavior Binding
|
||||
- Reference: `&caps_word`
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
&caps_word
|
||||
```
|
||||
- `&caps_on` enables caps lock
|
||||
- `&caps_off` disables caps lock
|
||||
- `&caps_hold` enables caps lock while held, and disables it when released
|
||||
- `&caps_word` enables caps lock, and disables it when a word separator is typed or the key is pressed again
|
||||
|
||||
### Configuration
|
||||
|
||||
#### Word Separators
|
||||
The following options allow to customize the caps lock behavior:
|
||||
|
||||
By default, the caps word will remain active until space (`SPACE`), tab (`TAB`), enter (`ENTER`), or escape (`ESCAPE`) is pressed. If you would like to override this, you can set a new array of keys in the `disable-on-keys` property in your keymap:
|
||||
- `enable-on-press`: whether to enable caps lock when the key is pressed
|
||||
- `disable-on-release`: whether to disable caps lock when the key is released
|
||||
- `disable-on-next-release`: whether to disable caps lock when the key is released a second time
|
||||
- `disable-on-keys`: list of keys after which caps lock is disabled
|
||||
|
||||
### Examples
|
||||
|
||||
The pre-configured `caps_word` enables caps lock when pressed, and disables it when `SPACE`, `TAB`, or `ENTER` is pressed, or the key is pressed again.
|
||||
|
||||
```
|
||||
&caps_word {
|
||||
disable-on-keys = <SPACE MINUS>;
|
||||
};
|
||||
|
||||
/ {
|
||||
keymap {
|
||||
...
|
||||
};
|
||||
caps_word: behavior_caps_word {
|
||||
compatible = "zmk,behavior-capslock";
|
||||
label = "CAPS_WORD";
|
||||
#binding-cells = <0>;
|
||||
bindings = <&kp CAPSLOCK>;
|
||||
enable-on-press;
|
||||
disable-on-next-release;
|
||||
disable-on-keys = <SPACE TAB ENTER>;
|
||||
};
|
||||
```
|
||||
|
||||
### Multiple Caps Words
|
||||
|
||||
If you want to use multiple caps words with different word separators, you can add additional caps word instances to use in your keymap:
|
||||
A key to activate caps lock and disable it only after typing a whole line can be defined as:
|
||||
|
||||
```
|
||||
/ {
|
||||
prog_caps: behavior_prog_caps_word {
|
||||
prog_caps: caps_line {
|
||||
compatible = "zmk,behavior-capslock";
|
||||
label = "CAPS_WORD";
|
||||
label = "CAPS_LINE";
|
||||
#binding-cells = <0>;
|
||||
bindings = <&kp CAPSLOCK>;
|
||||
enable-on-press;
|
||||
disable-on-second-press;
|
||||
disable-on-keys = <SPACE TAB ENTER ESCAPE>;
|
||||
disable-on-keys = <ENTER>;
|
||||
};
|
||||
|
||||
keymap {
|
||||
|
|
Loading…
Add table
Reference in a new issue