From 0d02441abe96010b95a88fa22f23b8676fccb262 Mon Sep 17 00:00:00 2001 From: Okke Formsma Date: Fri, 6 Nov 2020 21:34:36 +0100 Subject: [PATCH] docs(codes): add modifier functions Refactor and expand codes documentation to include modifier functions. Closes #330. --- docs/docs/codes/_keyboard-keypad.mdx | 2 ++ docs/docs/codes/modifiers.mdx | 42 ++++++++++++++++++++++++++++ docs/docs/dev-guide-new-shield.md | 4 +-- docs/docs/feature/keymaps.md | 8 +++--- docs/sidebars.js | 1 + docs/src/data/hid.js | 14 ++++++---- 6 files changed, 59 insertions(+), 12 deletions(-) create mode 100644 docs/docs/codes/modifiers.mdx diff --git a/docs/docs/codes/_keyboard-keypad.mdx b/docs/docs/codes/_keyboard-keypad.mdx index b1852d64..a00a4f4f 100644 --- a/docs/docs/codes/_keyboard-keypad.mdx +++ b/docs/docs/codes/_keyboard-keypad.mdx @@ -24,6 +24,8 @@ import Table from "@site/src/components/codes/Table"; ### Modifiers +The [Modifiers](./modifiers) page includes further information. + ### Locks diff --git a/docs/docs/codes/modifiers.mdx b/docs/docs/codes/modifiers.mdx new file mode 100644 index 00000000..9d8274cb --- /dev/null +++ b/docs/docs/codes/modifiers.mdx @@ -0,0 +1,42 @@ +--- +title: Modifiers +sidebar_label: Modifiers +hide_title: true +--- + +import OsLegend from "@site/src/components/codes/OsLegend"; +import ToastyContainer from "@site/src/components/codes/ToastyContainer"; +import Table from "@site/src/components/codes/Table"; + + + + +## Modifiers + +Modifiers are the special keyboard keys: _shift_, _alt_, _control_ & _GUI_. + +Modifiers can be used in two forms within ZMK: + +- Modifier [Keys](#modifier-keys) → `LEFT_SHIFT` +- Modifier [Functions](#modifier-functions) → `LS(code)` + +
+ +### Modifier Keys + +These act like any other key code. + +- e.g. `&kp LEFT_GUI` pushes and releases the left GUI key. + +### Modifier Functions + +These functions take the form: `XX(code)` + +- They _apply_ the modifier to another _code_. + - e.g. `&kp LS(A)` = `LEFT_SHIFT`+`A` + - aka a _shifted_ (capitalized) **A**. + - The _code_ and the _modifier_ are handled _as one_. +- They can be _combined_: + - e.g. `&kp LC(RA(B))` = `LEFT_CONTROL`+`RIGHT_ALT`+`B` +- Some codes _include_ modifiers in their definition. + - e.g. `DOLLAR` = `LS(N4)` diff --git a/docs/docs/dev-guide-new-shield.md b/docs/docs/dev-guide-new-shield.md index f3491ddd..63871cdb 100644 --- a/docs/docs/dev-guide-new-shield.md +++ b/docs/docs/dev-guide-new-shield.md @@ -368,12 +368,12 @@ Here is an example simple keymap for the Kyria, with only one layer: // -------------------------------------------------------------------------------------------------------------------------------------------------------------------- // | ESC | Q | W | E | R | T | | Y | U | I | O | P | \ | // | TAB | A | S | D | F | G | | H | J | K | L | ; | ' | -// | SHIFT | Z | X | C | V | B | L SHIFT | L SHIFT | | L SHIFT | L SHIFT | N | M | , | . | / | R CTRL | +// | SHIFT | Z | X | C | V | B | CTRL+A | CTRL+C | | CTRL+V | CTRL+X | N | M | , | . | / | R CTRL | // | GUI | DEL | RETURN | SPACE | ESCAPE | | RETURN | SPACE | TAB | BSPC | R ALT | bindings = < &kp ESC &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp BSLH &kp TAB &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SEMI &kp QUOTE - &kp LSHFT &kp Z &kp X &kp C &kp V &kp B &kp LSHFT &kp LSHFT &kp LSHFT &kp LSHFT &kp N &kp M &kp COMMA &kp DOT &kp FSLH &kp RCTRL + &kp LSHFT &kp Z &kp X &kp C &kp V &kp B &kp LC(A) &kp LC(C) &kp LC(V) &kp LC(X) &kp N &kp M &kp COMMA &kp DOT &kp FSLH &kp RCTRL &kp LGUI &kp DEL &kp RET &kp SPACE &kp ESC &kp RET &kp SPACE &kp TAB &kp BSPC &kp RALT >; diff --git a/docs/docs/feature/keymaps.md b/docs/docs/feature/keymaps.md index 203b9408..f9a28946 100644 --- a/docs/docs/feature/keymaps.md +++ b/docs/docs/feature/keymaps.md @@ -130,12 +130,12 @@ that defines just one layer for this keymap: // -------------------------------------------------------------------------------------------------------------------------------------------------------------------- // | ESC | Q | W | E | R | T | | Y | U | I | O | P | \ | // | TAB | A | S | D | F | G | | H | J | K | L | ; | ' | -// | SHIFT | Z | X | C | V | B | L SHIFT | L SHIFT | | L SHIFT | L SHIFT | N | M | , | . | / | R CTRL | +// | SHIFT | Z | X | C | V | B | CTRL+A | CTRL+C | | CTRL+V | CTRL+X | N | M | , | . | / | R CTRL | // | GUI | DEL | RETURN | SPACE | ESCAPE | | RETURN | SPACE | TAB | BSPC | R ALT | bindings = < &kp ESC &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp BSLH &kp TAB &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SEMI &kp QUOTE - &kp LSHFT &kp Z &kp X &kp C &kp V &kp B &kp LSHFT &kp LSHFT &kp LSHFT &kp LSHFT &kp N &kp M &kp COMMA &kp DOT &kp FSLH &kp RCTRL + &kp LSHFT &kp Z &kp X &kp C &kp V &kp B &kp LC(A) &kp LC(C) &kp LC(V) &kp LC(X) &kp N &kp M &kp COMMA &kp DOT &kp FSLH &kp RCTRL &kp LGUI &kp DEL &kp RET &kp SPACE &kp ESC &kp RET &kp SPACE &kp TAB &kp BSPC &kp RALT >; @@ -167,12 +167,12 @@ Putting this all together, a complete [`kyria.keymap`](https://github.com/zmkfir // -------------------------------------------------------------------------------------------------------------------------------------------------------------------- // | ESC | Q | W | E | R | T | | Y | U | I | O | P | \ | // | TAB | A | S | D | F | G | | H | J | K | L | ; | ' | -// | SHIFT | Z | X | C | V | B | L SHIFT | L SHIFT | | L SHIFT | L SHIFT | N | M | , | . | / | R CTRL | +// | SHIFT | Z | X | C | V | B | CTRL+A | CTRL+C | | CTRL+V | CTRL+X | N | M | , | . | / | R CTRL | // | GUI | DEL | RETURN | SPACE | ESCAPE | | RETURN | SPACE | TAB | BSPC | R ALT | bindings = < &kp ESC &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp BSLH &kp TAB &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SEMI &kp QUOTE - &kp LSHFT &kp Z &kp X &kp C &kp V &kp B &kp LSHFT &kp LSHFT &kp LSHFT &kp LSHFT &kp N &kp M &kp COMMA &kp DOT &kp FSLH &kp RCTRL + &kp LSHFT &kp Z &kp X &kp C &kp V &kp B &kp LC(A) &kp LC(C) &kp LC(V) &kp LC(X) &kp N &kp M &kp COMMA &kp DOT &kp FSLH &kp RCTRL &kp LGUI &kp DEL &kp RET &kp SPACE &kp ESC &kp RET &kp SPACE &kp TAB &kp BSPC &kp RALT >; diff --git a/docs/sidebars.js b/docs/sidebars.js index f05cd056..15d531ec 100644 --- a/docs/sidebars.js +++ b/docs/sidebars.js @@ -29,6 +29,7 @@ module.exports = { Codes: [ "codes/index", "codes/keyboard-keypad", + "codes/modifiers", "codes/editing", "codes/media", "codes/applications", diff --git a/docs/src/data/hid.js b/docs/src/data/hid.js index 1f7daa7c..d52331f9 100644 --- a/docs/src/data/hid.js +++ b/docs/src/data/hid.js @@ -4059,7 +4059,7 @@ export default [ footnotes: {}, }, { - names: ["LEFT_CONTROL", "LCTRL"], + names: ["LEFT_CONTROL", "LCTRL", "LC(code)"], description: "Left Control", context: "Keyboard", clarify: false, @@ -4080,7 +4080,7 @@ export default [ footnotes: {}, }, { - names: ["LEFT_SHIFT", "LSHFT"], + names: ["LEFT_SHIFT", "LSHFT", "LS(code)"], description: "Left Shift ⇧", context: "Keyboard", clarify: false, @@ -4101,7 +4101,7 @@ export default [ footnotes: {}, }, { - names: ["LEFT_ALT", "LALT"], + names: ["LEFT_ALT", "LALT", "LA(code)"], description: "Left Alt", context: "Keyboard", clarify: false, @@ -4125,6 +4125,7 @@ export default [ names: [ "LEFT_GUI", "LGUI", + "LG(code)", "LEFT_WIN", "LWIN", "LEFT_COMMAND", @@ -4152,7 +4153,7 @@ export default [ footnotes: {}, }, { - names: ["RIGHT_CONTROL", "RCTRL"], + names: ["RIGHT_CONTROL", "RCTRL", "RC(code)"], description: "Right Control", context: "Keyboard", clarify: false, @@ -4173,7 +4174,7 @@ export default [ footnotes: {}, }, { - names: ["RIGHT_SHIFT", "RSHFT"], + names: ["RIGHT_SHIFT", "RSHFT", "RS(code)"], description: "Right Shift ⇧", context: "Keyboard", clarify: false, @@ -4194,7 +4195,7 @@ export default [ footnotes: {}, }, { - names: ["RIGHT_ALT", "RALT"], + names: ["RIGHT_ALT", "RALT", "RA(code)"], description: "Right Alt", context: "Keyboard", clarify: false, @@ -4218,6 +4219,7 @@ export default [ names: [ "RIGHT_GUI", "RGUI", + "RG(code)", "RIGHT_WIN", "RWIN", "RIGHT_COMMAND",