-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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): Smart-layers (e.g., num-word) and caps-word enhancements #1451
base: main
Are you sure you want to change the base?
Conversation
bacf72e
to
a3eb244
Compare
Unless I did something incorrectly, this seems to only work on keys N1-N6, it does not work properly for KP_N0-KP_N9, nor KP_DOT. I don't believe I did something incorrectly, otherwise it would not work for the N1-6 keys, I expect. If I tap &num_word, KP_N0-9 will insert a single number and then the keypad layer will deactivate. If I hit plain N1-6 on the number row across the top, it will remain in the numeric layer. Do I have to do something specific/different for this to stay on the keypad layer when using KP_N numbers as opposed to using N numbers? I have the ignore-numbers bool enabled as per the example listed above. Behavior implementation: Key implementation: line 38/col 65 |
The
|
Good call, that did the trick. I do appreciate it. 👍
|
I'm using num_word through urob/zmk and I noticed pressing !@#$% (EXLAMATION, AT, HASH, ...) through unshifted keymaps don't toggle off the layer, but -+~ etc. do. |
Yes, the current implementation does not distinguish between shifted/unshifted keycodes. So all symbols that under the hood are implemented via shift + number won't trigger the exit condition. For now, you could use tri-state as an alternative, allowing you to define exit conditions purely based on key positions. |
Squashed commit of the following: commit ba38925 Author: urob <978080+urob@users.noreply.github.com> Date: Fri Aug 5 16:05:58 2022 -0400 Ignore-modifiers property for capsword
Just wanted to drop by and thank you @urob! This made an incredible difference in comfort, cognitive ease and speed on my keymap. Feels so intuitive now! https://github.com/minusfive/zmk-config Wondering whether there are any plans of merging this to main? Feels like a no-brainer for a native feature, and I know there are already a ton of users, right? |
@maintainers could we please get this merged for the next release? It's an excellent feature that doesn't break anything (as far as I can see), and a lot of people would love to see it on mainline ZMK |
I also love this feature and it’s working well. It hasn’t received any feedback from the maintainers, but I imagine squeezing these features into the caps word implementation isn’t the way to go. I think either defining a new behavior or adding it to the layer-toggle behavior would probably be more appropriate. |
First off, I really enjoy all the work @urob has been doing and I'm using his ZMK repo for my stuff as well. But regarding this functionality here I came upon one issue with my numbers layer that is definitely related to the layer addition (which capsword does not use). That is that an This should actually be reproducable with urobs own keymap directly (e.g. try the swapper or any F## key with numword active). |
I have been pondering about the future of this PR. The current proposal generalizes -- or perhaps more fittings: piggybacks on -- But design-wise I am wondering whether it would make sense to split off the backend behavior for "smart layers" from the one for "caps word" (especially in light of #1742 which adds some more customization options for the latter)? Specifically, I am thinking of a more focused |
@urob with your new implementation idea, how would you make a caps-word that ignore modifiers? Keep it in caps-word in a separate PR? |
At some point @joelspadin seemed open to add this to #1742. I am not sure what the current verdict is but IMHO this would be the best solution. Otherwise, I could also open a new PR for just that. |
@urob how about a behavior that doesn’t define an allowed list at all? Instead it could just be “smart layer toggle”, which turns on a layer and if a none or trans behavior on it is hit, the layer is deactivated. People have been using your PR to implement smart nav and symbol layers. This would allow to create a generalized implementation that doesn’t need any customization for those. |
I just want to get #1742 merged first, and then I can look into more enhancements like allowing it to cancel when modifiers are pressed (assuming I understand what you're wanting to do). |
That makes a lot of sense. Instead of a What I am not sure atm is how hard it would be to switch to a condition model that's behavior-based and is able to detect |
I will soon start working on a feature that needs the same functionality and recently asked about it in the #development discord channel. Currently there is only a "pretty gross" way to accomplish it without adding new trans and none behaviors. But if a major feature like your num layer implementation is using it and I also need it, then maybe it would make sense to turn the "dirty way" into a proper API or notification event. |
I would agree that the ability to cancel using I was initially going to suggest having different "flavors" of the smart layer behavior, like the hold tap behavior has to specify a 'cancel-list' flavor, or a 'continue-list' flavor. But, I cannot think of an instance when you would need the continue-list if it is switching to a different layer and you cancel out with |
I implemented this a new module: https://github.com/urob/zmk-auto-layer To keep the new behavior focused, I dropped all of the original caps-word functionality. I won't be updating this PR for now so that anyone using the old implementation can still access it. If there is sufficient demand for updating this PR with the new implementation or opening a new one, I might do so in the future. |
For now this PR should continue to work. In the long-run, I prefer to re-create something new on top of #1742. Note that #1742 includes a The only thing currently missing is a way to terminate |
EDIT: The PR is somewhat outdated. An updated version focusing on the auto-layer functions is available as ZMK module
This PR contains a number of enhancements for the caps-word behavior. Most importantly it adds a smart-layer option that activates a layer until a key not in
continue-list
is pressed. The PR supersedes #1422New/updated backend-properties:
The backend behavior
zmk,behavior-caps-word
(not to be confused with the frontend&caps_word
) now supports the following config options:mods
: Specifies the mods that get activated when smart-word is active. New default:0
(none).layers
: Specifies the layer that gets activated when smart-word is active. Default:-1
(none)ignore-alphas
: If true, alphas do not cancel the smart-word behaviorignore-numbers
: If true, numbers do not cancel the smart-word behaviorignore-modifiers
: If true, modifiers do not cancel the smart-word behaviorThe new
layers
property is used to configure the new smart-layers capabilities. The newignore-*
flags can be used to configure whether smart-word continues on alphas, numbers or modifiers (the original caps-word would always continue on all of these regardless of the value ofcontinue-list
)Smart-layer example: Num-word
For instance, to set up a "numword", one can define a new behavior as follows:
Pressing
&num_word
will activate the number-layer and keep it active for as long as only numbers, backspace, space, dot or comma are pressed. After any other key is pressed, say, "space", the layer is automatically deactivated. This works well if the number-layer is mostly transparent, so that one can just continue typing normally after finishing with the numbers without having to actively release the number-layer.For convenience, the PR also adds a pre-defined
&num_word
behavior. To use it, one only needs to specify the correct layer specification in the user config:Caps-word
The pre-defined caps-word definition has been adjusted to yield the old behavior using the new configuration-flags:
On the user-side nothing changes when using
&caps_word
.Using ignore-flags to tweak caps-word
For backwards-compatibility, the frontend implementation of
&caps_word
continues on all alphas, numbers and modifiers. This can be overwritten using/delete-property/
. For instance, to cancel caps-word when numbers and modifiers are pressed, one can add the following to the user config:This is useful, for example, for people who activate caps-word with somewhat complex key combos or tap dances and who wish to be able to deactivate it by simply pressing LEFT_SHIFT (of course, it still deactivates automatically with any other key not specified in
continue-list
). This fixes #1410.If one wants more fine-grained control over which modifiers or numbers cancel caps-word, one can use
continue-list
to do so. For example, if one wants to continue caps-word on shift but cancel it with all other modifiers, one can do so by adding the following to the user-config:Discussion
Would it make sense to rename the backend-behavior from
zmk,behavior-caps-word
to something likezmk,behavior-smart-word
? It might be a bit confusing that thezmk,behavior-caps-word
backend (which can be used to implement any smart-modifier or smart-layer) has almost exactly the same name as the&caps_word
frontend that setsmods
toMOD_LSFT
andlayers
to-1
(none).