You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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>.
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.
However the pattern get_mods() & <mod mask> == <mod mask> does not check if only a specific set is active at a time. This expression is also true when a mod is pressed together with the specific mod.
I think the correct pattern is get_mods() == <mod mask>
I am not a QMK expert, but something I noticed with the first code example in feature_advanced_keycodes.md: should the first code example be implemented with Key Overrides?
The text was updated successfully, but these errors were encountered:
Issue Description
The feature_advanced_keycodes.md has this part:
However the pattern
get_mods() & <mod mask> == <mod mask>
does not check if only a specific set is active at a time. This expression is also true when a mod is pressed together with the specific mod.I think the correct pattern is
get_mods() == <mod mask>
I am not a QMK expert, but something I noticed with the first code example in feature_advanced_keycodes.md: should the first code example be implemented with Key Overrides?
The text was updated successfully, but these errors were encountered: