Skip to content

Commit

Permalink
expand docs and give example
Browse files Browse the repository at this point in the history
  • Loading branch information
ecstatic-morse committed Feb 13, 2024
1 parent 16791aa commit e8ce540
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions docs/docs/behaviors/layers.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,11 @@ It is possible to use "toggle layer" to have keys that raise and lower the layer

## Momentary Layer Lock

Even if you mostly use momentary layers, it's occasionally useful to permanently enable a layer without needing to hold anything down. Instead of creating a separate `&tog` or `&to` binding for each layer, you can use `&molock`.
Even if you mostly use [momentary layers](#momentary-layer) instead of `&to` or `&tog`, it's occasionally useful to permanently enable a layer without needing to hold anything down. Instead of creating an additional `&tog` or `&to` binding for each such layer, you can use `&molock`.

`&molock` causes all currently active momentary layers not to be deactivated when `&mo` is released. If no momentary layers are active, `&molock` triggers a fallback behavior, which by default returns to the base layer (`&to 0`), deactivating any locked momentary layers in the process. Alternatively, the user can deactivate a single locked momentary layer by pressing and releasing the corresponding `&mo` binding again.
If `&molock` is pressed while any number of `&mo` bindings are being held, those momentary layers will not be deactivated when the corresponding `&mo` key is released. As a result, those momentary layers become "locked" until that `&mo` key is pressed and released a second time or the layer becomes deactivated by some other means (e.g. a `&tog` binding for that layer or a `&to` binding for a lower one).

If `&molock` is pressed while no `&mo` bindings are being held, it triggers a user-configurable fallback behavior. The default fallback behavior returns to the base layer (`&to 0`), deactivating any locked momentary layers in the process.

### Behavior Binding

Expand All @@ -165,6 +167,34 @@ Example:
&molock
```

Lock a symbol layer:

```dts
// Holding down the leftmost key (`&mo SYMS`), then pressing and releasing
// the rightmost key (`&molock`), will lock the symbol layer.
// Even after releasing the leftmost key, the symbol layer remains active.
//
// To return to the base layer, press and release either the leftmost key
// (triggering the `&mo SYMS` behavior a second time) or the rightmost key
// (triggering the default fallback behavior for `&molock`).
#define BASE 0
#define SYMS 1
/ {
keymap {
compatible = "zmk,keymap";
base_layer {
bindings = <&mo SYMS &kp Z &kp M &kp K >;
};
symbol_layer {
bindings = <&trans &kp PLUS &kp MINUS &molock>;
};
};
};
```

### Configuration

You can configure a different fallback behavior by overriding the `bindings` property of the built-in `&molock` behavior. For example, to return to layer 1 (instead of layer 0):
Expand Down

0 comments on commit e8ce540

Please sign in to comment.