summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprecondition <57645186+precondition@users.noreply.github.com>2023-04-21 03:41:53 +0200
committerGitHub <noreply@github.com>2023-04-20 19:41:53 -0600
commit974c01b4f845927ad3922ae62793c33187f5852c (patch)
treedf8a20af87338b09aca2d5b0a996255ba87c3061
parent387b64a79b4b86436205ffcb349214d594c9dcef (diff)
[Docs] Fix suggested code pattern when a specific mod-mask is required. (#20512)
-rw-r--r--docs/feature_advanced_keycodes.md6
1 files changed, 3 insertions, 3 deletions
diff --git a/docs/feature_advanced_keycodes.md b/docs/feature_advanced_keycodes.md
index 90f06e405a..3da5e7b32f 100644
--- a/docs/feature_advanced_keycodes.md
+++ b/docs/feature_advanced_keycodes.md
@@ -37,9 +37,9 @@ For more information on bitwise operators in C, click [here](https://en.wikipedi
In practice, this means that you can check whether a given modifier is active with `get_mods() & MOD_BIT(KC_<modifier>)` (see the [list of modifier keycodes](keycodes_basic.md#modifiers)) or with `get_mods() & MOD_MASK_<modifier>` if the difference between left and right hand modifiers is not important and you want to match both. Same thing can be done for one-shot modifiers if you replace `get_mods()` with `get_oneshot_mods()`.
-To check that *only* a specific set of mods is active at a time, AND the modifier state and your desired mod mask as explained above and compare the result to the mod mask itself: `get_mods() & <mod mask> == <mod mask>`.
+To check that *only* a specific set of mods is active at a time, use a simple equality operator: `get_mods() == <mod mask>`.
-For example, let's say you want to trigger a piece of custom code if one-shot left control and one-shot left shift are on but every other one-shot mods are off. To do so, you can compose the desired mod mask by combining the mod bits for left control and shift with `(MOD_BIT(KC_LCTL) | MOD_BIT(KC_LSFT))` and then plug it in: `get_oneshot_mods() & (MOD_BIT(KC_LCTL) | MOD_BIT(KC_LSFT)) == (MOD_BIT(KC_LCTL) | MOD_BIT(KC_LSFT))`. Using `MOD_MASK_CS` instead for the mod bitmask would have forced you to press four modifier keys (both versions of control and shift) to fulfill the condition.
+For example, let's say you want to trigger a piece of custom code if one-shot left control and one-shot left shift are on but every other one-shot mods are off. To do so, you can compose the desired mod mask by combining the mod bits for left control and shift with `(MOD_BIT(KC_LCTL) | MOD_BIT(KC_LSFT))` and then plug it in: `get_oneshot_mods() == (MOD_BIT(KC_LCTL) | MOD_BIT(KC_LSFT))`. Using `MOD_MASK_CS` instead for the mod bitmask would have forced you to press four modifier keys (both versions of control and shift) to fulfill the condition.
The full list of mod masks is as follows:
@@ -184,4 +184,4 @@ This page used to encompass a large set of features. We have moved many sections
## Key Overrides :id=key-overrides
-* [Key Overrides](feature_key_overrides.md) \ No newline at end of file
+* [Key Overrides](feature_key_overrides.md)