Skip to content
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

Feature Request: New &df layer behaviour #1299

Open
manna-harbour opened this issue May 13, 2022 · 3 comments · May be fixed by #1984
Open

Feature Request: New &df layer behaviour #1299

manna-harbour opened this issue May 13, 2022 · 3 comments · May be fixed by #1984

Comments

@manna-harbour
Copy link

I'd like to be able to lock a momentary layer. That is, while holding &mo or &lt, tap the layer lock key then release the layer hold but stay on the layer.

&to can not be used as the layer is deactivated when the layer hold is released. &tog can not be used as it deactivates the layer immediately.

QMK has DF, and KMonad has layer-switch, that can be used for this purpose.

I propose adding a new &df layer behaviour to change the default layer.

See the discord comment thread starting here for an earlier discussion on this topic.

@dabell-cc
Copy link
Contributor

Could you make use of the example behaviour shown in the "Toggle-on-Tap, Momentary-on-Hold Layers" example found on the Hold-Tap Behaviour page?

I set my keymap up to allow a 'Fn' key that will toggle the F1..F12 keys layer on when tapped, but allow Fn+F1..F12 to be used without then having to un-toggle the layer. A note of caution though, the documentation currently has the <&tog>, <&mo> bindings reversed so you'll want to switch them. (I put in a PR for it earlier today).

I suppose you might not want to dedicate a key to this behaviour, such as the &lt use case, where the tap might be a character entry key.

@bmijanovich
Copy link

Below is an example of how to achieve a layer lock using Conditional Layers. By allowing two separate layers to each control the state of the layer you want to lock, you can avoid the layer deactivating when you release &mo after pressing &tog (or &to).

The key points here are:

  • You are not limited to a single Conditional Layer condition
  • Conditional Layer conditions do not require 2 or more if-layers; 1 will do just fine
  • Since the LOWER layer is controlled by Conditional Layers, you cannot activate it directly; you must instead activate it indirectly using one of the if-layers
#define DEFAULT 0
#define LOWER 1
#define LOWER_TEMP 2
#define LOWER_LOCK 3

/ {
    conditional_layers {
        compatible = "zmk,conditional-layers";
        lower_temp {
            if-layers = <LOWER_TEMP>;
            then-layer = <LOWER>;
        };
        lower_lock {
            if-layers = <LOWER_LOCK>;
            then-layer = <LOWER>;
        };
    };
    keymap {
        compatible = "zmk,keymap";
        default_layer {
            bindings = <
                &mo LOWER_TEMP    &kp A    &kp B
            >;
        };
        lower_layer {
            bindings = <
                &trans    &tog LOWER_LOCK    &kp C
            >;
        };
        lower_temp_layer {
            bindings = <
                &trans    &trans    &trans
            >;
        };
        lower_lock_layer {
            bindings = <
                &trans    &trans    &trans
            >;
        };
    };
};

I wrote this on my phone so no guarantees about it being bug free or even compiling. The approach works though; I use it in my keymap for exactly this feature.

@ecstatic-morse ecstatic-morse linked a pull request Nov 2, 2023 that will close this issue
@ecstatic-morse
Copy link

I implemented a basic version of this in #1984 and am using it locally. I'm curious how my version compares to what others had in mind. For example, I think a caps word-like option to disable locked layers would be useful, but it would be a bit difficult to configure...

SethMilliken pushed a commit to SethMilliken/zmk-config that referenced this issue Dec 16, 2023
amacleod added a commit to amacleod/zmk-config that referenced this issue Jun 2, 2024
All layouts should now have escape and tab on them, and to get
backspace on Hands Down Gold there are escape, backspace, and tab on
the nav layer now. I imitated the technique described in
zmkfirmware/zmk#1299 (comment)
to use conditional layers for num-lock.
amacleod added a commit to amacleod/zmk-config that referenced this issue Jun 3, 2024
* Attempting to chop off the 6th column.

* Adding chosen five_column_transform.

* Dvorak as layer 0

* Trimming keyboard diagrams.

Removed leftmost and rightmost columns and added a little more line drawing.

* Lots of keymap additions.

Trying to make a cycle of base layouts that can be chosen in sequence:
Hands Down Neu, Hands Down Gold, Dvorak, Colemak-DH, QWERTY, Canary
Ortho, Sturdy. Also replaced "lower" and "raise" layers with symbol
layer (inspired by Pascal Getreuer), navigation layer, and a numpad
layer with F-keys.

* Correct typos: UNDS -> UNDER

* Putting in required binding-cells directives.

Though I do not understand why they are required nor what they mean.

* Typo: removing rogue lowercase t.

* Rearranging to get ESC and TAB and trying to fix numpad lock.

All layouts should now have escape and tab on them, and to get
backspace on Hands Down Gold there are escape, backspace, and tab on
the nav layer now. I imitated the technique described in
zmkfirmware/zmk#1299 (comment)
to use conditional layers for num-lock.

* Missed a semicolon.

* Fix typo: LAYOUT -> LAYOUTS

* Missed the O in HD Neu.

No idea how that Z got in there.

* Making left thumb key also exit numlock.

Also updated copyright statement and added a to-do list.

* Trying homerow shift on pinkies and swapping space and backspace.

* Adjusting tapping term a little bit, and notes on homerow mods feel.

---------

Co-authored-by: keymap-editor[bot] <91849743+keymap-editor[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants