-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(behaviors): lazy sticky keys #1812
Conversation
d34a856
to
b8065fe
Compare
I force-pushed a V2 of this feature. This time, all the tests work, and a lot of edge cases were solved, especially with compound behaviors. This PR now introduces two breaking changes to the regular sticky key behavior. These changes make more sense to me, and play nicer with the way lazy sticky keys are implemented, but can be reverted if necessary. Sticky Release OrderPreviously, the order of events emitted for a sticky mod (sticky tapped -> other key tapped) would be: Specifically, when the other key is released, my PR ensures the other key is released before the sticky key is released, not the other way around. This means that the sticky key now properly sends its keycodes "around" the other key. Timeout while other key heldPreviously, when the sticky key is tapped, and then the other key is held indefinitely, the sticky key will release on timeout even if the other key is held. My PR changes this to release if and only if the other key is released, so the sticky key is again always "around" the other key. This was mostly changed due to implementation reasons for lazy keys. I think this behavior is more reasonable, however, as it feels strange for a sticky key to release mid-hold. Note that the behavior for DiscussionThis PR is now fully ready for review. I'd love feedback if these changes are reasonable, or if there are any situations where they would be a regression. |
Note that tapping a lazy sticky key will not trigger other behaviors such as the release of other sticky keys or layers. If you want to use a lazy sticky key to activate the release of a sticky layer, potential solutions include wrappping the sticky key in a simple macro which presses the sticky behavior around the sticky key press, doing the same with |
b8065fe
to
4b1b49a
Compare
Bump - this is a nice improvement to sticky keys that help with layouts using sticky keys on OSs like windows. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it! A few questions on the implementation. Thanks!
for (int i = 0; i < ZMK_BHV_STICKY_KEY_MAX_HELD; i++) { | ||
struct active_sticky_key *sticky_key = sticky_keys_to_press_before_reraise[i]; | ||
if (sticky_key) { | ||
press_sticky_key_behavior(sticky_key, ev_copy.timestamp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to clear if from sticky_keys_to_press_before_reraise
now that it's pressed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will only loop once through the array before discarding it (and it is null-initialized). The purpose is simply to collect all the out-of-order presses (of just-in-time mods) and releases (of expired mods) and execute them in order "around" the other key.
app/tests/sticky-keys/11-lazy-timeout-during/native_posix_64.keymap
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs LGTM (not doing an approve to not confuse the rest of the review situation)
034bc98
to
f105579
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
This PR adds a new feature to sticky keys.
New properties
lazy
By default, sticky keys are activated on press until another key is pressed. You can enable the
lazy
setting to instead activate the sticky key right before the other key is pressed. This is useful for mouse interaction or situations where you don't want the host to see anything during a sticky-key timeout, for example&sk LGUI
, which can trigger a menu if pressed alone.Discussion
This PR is fairly straightforward. I use it along with
hold-while-undecided
(#1811) to make nice callum-style sticky mods that are invisible to the OS and don't interfere with mouse interactions. I can also use it withouthold-while-undecided
to make a stickyLGUI
that doesn't trigger the OS menu upon timeout.