feat(combos): add partial combo holds and slow release positions #1809
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains two enhancements for combos. While the usecase is relatively niche, I hope I can convey the power of these features.
New properties:
Partial Holds
When a combo is pressed, and then one key is released, adding
partial-hold-position
to the combosbindings
array allows you to control what happens to the remaining keys that are being held.Slow Release Positions
slow-release-positions
is an array that lets you precisely control the conditions to maintainslow-release
.Documentation
Slow Release
If you want the combo binding to be released when all positions are released, instead of when any position is released, enable
slow-release
. This is useful for combos that are used to toggle a layer, for example.However, you may want to continue to hold the combo when one position is held but not the other. For example, if the keys corresponding to the combo positions 0 and 1 are
&mo NAV
and&kp A
, and the combo behavior is&kp LEFT
, you may want to continue holdingLEFT
while you holdA
and releaseNAV
, but not if you holdNAV
and releaseA
. To solve this, you can specifyslow-release-positions
to select which keys must be held to maintainslow-release
. In this example, you would specifyslow-release-positions = <1>
. In other words, the combo will be held as long all keys inslow-release-positions
are held, and released when any key inslow-release-positions
is released.Partial Holds
After pressing a combo, you may want to specify the behavior that is activated when the combo is partially released. For example, if the keys corresponding to the combo positions 0, 1, and 2 are
&tog NAV
,&kp A
, and&kp LSFT
and the combo behavior is&kp LEFT
, you may want to activate&mo NAV
when you releaseA
orLSFT
but continue to holdNAV
, or activateLSFT
when you releaseNAV
orA
but continue to holdLSFT
.To do this, you can add
partial-hold-position
to thebindings
array, optionally along with associated behaviors. When no explicit behavior is specified, it will default to the behavior belonging to the key position.In this example, you would specify:
Partial Hold with Slow Release Positions
Partial holds compliment
slow-release-positions
, by letting you control what happens when a combo is partially released. The best motivating example is a combo that is used to "accelerate" an existing thumb momentary layer with a key on that layer, allowing you to mash the keys together at the same time. The following layout is an example of this:In this example, you can press
LEFT
by pressingNAV
, pressingLEFT
, then releasingNAV
. However, this requires a slight pause to ensureNAV
was pressed beforeLEFT
, so thatA
isn't pressed instead. What if you wanted to be able to mash the keys together at the same time, and achieve a consistent result? This is what the combo does — it allows you to pressLEFT
up to 50ms beforeNAV
and still activateLEFT
.However, the introduction of the combo means that you can no longer release
LEFT
while holdingNAV
then pressRIGHT
. This is because the combo will be released whenLEFT
is released, andB
will be pressed instead. To solve this, you can usepartial-hold-position
to specify thatNAV
should be pressed whenLEFT
is released. Finally, you can useslow-release-positions
to specify that the combo should be held as long asLEFT
is held, allowing you to use key-repeat while holdingLEFT
but releasingNAV
.Discussion
Before I write tests, I would love to hear feedback on the concept and implementation. There were a few partial-hold implementations I tried, including having a
partial-hold-positions
array. However, that implementation did not allow setting a custom behavior to the position. Also, I'm open to suggestions for naming - I also considered "partial combo releases".