From c77fbc5a24f6863ead738dfdb37847f0dfdf838c Mon Sep 17 00:00:00 2001 From: Cem Aksoylar Date: Sun, 24 Sep 2023 23:22:44 -0700 Subject: [PATCH] Add behavior examples --- docs/blog/2023-09-15-zmk-sotf-6.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/docs/blog/2023-09-15-zmk-sotf-6.md b/docs/blog/2023-09-15-zmk-sotf-6.md index 91520da8..f7623086 100644 --- a/docs/blog/2023-09-15-zmk-sotf-6.md +++ b/docs/blog/2023-09-15-zmk-sotf-6.md @@ -27,10 +27,38 @@ Here's a summary of the various major changes since last time, broken down by th [aumuell](https://github.com/aumuell), [vrinek](https://github.com/vrinek) and [urob] contributed to improving the behavior of [mod-morphs](../docs/behaviors/mod-morph.md) by masking the triggering modifiers and added `keep-mods` property in [#1412](https://github.com/zmkfirmware/zmk/pull/1412). This unlocks more use cases for mod-morphs, since you are no longer constrained to emitting keycodes that work well with the triggering modifier keycodes. +As an example, you can now define a mod-morph that swaps `;` and `:` so that the former is the shifted version of the latter, which wasn't previously possible: + +```dts + col_semi: colon_semicolon { + compatible = "zmk,behavior-mod-morph"; + label = "COLON_SEMICOLON"; + #binding-cells = <0>; + bindings = <&kp COLON>, <&kp SEMI>; + mods = <(MOD_LSFT|MOD_RSFT)>; + }; +``` + #### Parameterized macros [petejohanson] added [macros that can be parameterized](../docs/behaviors/macros.md#parameterized-macros) with one or two parameters in [#1232](https://github.com/zmkfirmware/zmk/pull/1232). This allows users to define macros in a more modular way and is a nice quality-of-life improvement. +As a simple example, you could define a macro that puts any keycode provided between double quotes as below and use it like `&ql_macro A` in your keymap: + +```dts + ql_macro: quote_letter_macro { + #binding-cells = <1>; + label = "QUOTE_LETTER"; + compatible = "zmk,behavior-macro-one-param"; + bindings = + <&kp DQT>, + <¯o_param_1to1 &kp MACRO_PLACEHOLDER>, + <&kp DQT>; + }; +``` + +Please see the documentation page linked above for usage and more examples. + #### Arbitrary behaviors on encoder rotation [nickconway](https://github.com/nickconway) and [petejohanson] added [sensor rotation behaviors](../docs/behaviors/sensor-rotate.md) to allow invoking arbitrary behaviors from encoders [#1758](https://github.com/zmkfirmware/zmk/pull/1758). Previously encoder rotations could only invoke the key-press behavior `&kp` through the `&inc_dec_kp` binding, whereas now you can define new sensor rotation behaviors to invoke others.