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

Disable Auto shift when LGUI is pressed (for copy or other actions) #1190

Open
Vasilis opened this issue Mar 27, 2022 · 7 comments
Open

Disable Auto shift when LGUI is pressed (for copy or other actions) #1190

Vasilis opened this issue Mar 27, 2022 · 7 comments

Comments

@Vasilis
Copy link

Vasilis commented Mar 27, 2022

Hi, everyone! I recently enabled auto-shift on my Corne-ish Zen. That works fine except for the copy - paste commands where instead of LGUI+C, what is sent is LGUI+SHIFT+C if I accidentally hold it for longer than tapping-term-ms.

Is it possible to prevent the hold-tap behavior altogether when LGUI (or any other key) is pressed before? I tried the following unsuccessfully:

        behaviors {
                as: auto_shift {
                        compatible = "zmk,behavior-hold-tap";
                        label = "AUTO_SHIFT";
                        #binding-cells = <2>;
                        tapping-term-ms = <210>;
                        quick-tap-ms = <0>;
                        flavor = "tap-preferred";
                        bindings = <&kp>, <&kp>;
                };
                modcp: mod_copy {
                        compatible = "zmk,behavior-mod-morph";
                        label = "MOD_COPY";
                        #binding-cells = <0>;
                        bindings = <___C___>, <MAC_COPY>;
                        mods = <(MOD_LGUI | MOD_RGUI)>;
                };
                modpst: mod_paste {
                        compatible = "zmk,behavior-mod-morph";
                        label = "MOD_PASTE";
                        #binding-cells = <0>;
                        bindings = <___V___>, <MAC_PASTE>;
                        mods = <(MOD_LGUI | MOD_RGUI)>;
                };
        };
@MatCyg
Copy link

MatCyg commented Mar 28, 2022

Here you go for the copy (remember to use mod morph in the keymap):

as: auto_shift {
        compatible = "zmk,behavior-hold-tap";
        label = "AUTO_SHIFT";
        #binding-cells = <2>;
        tapping-term-ms = <210>;
        quick-tap-ms = <0>;
        flavor = "tap-preferred";
        bindings = <&kp>, <&kp>;
};
modcp: mod_copy {
        compatible = "zmk,behavior-mod-morph";
        label = "MOD_COPY";
        #binding-cells = <0>;
        bindings = <&as LS(C) C>, <&kp C>;
        mods = <(MOD_LGUI | MOD_RGUI)>;
};

usage in keymap:
&modcp          

@Vasilis
Copy link
Author

Vasilis commented Mar 28, 2022

Thanks for your time, @MatCyg! Unfortunately, this still does not work (at least, on a Corne-ish Zen).

I assigned &modcp to C in the keymap and, still, if I press LGUI+C for longer than tapping-term-ms, it will still output the autoshift (&as LS(C) C) with shift in the mix... :/

Depending on the active application, the behavior may be the undesired one (for instance on a browser it brings up the developer section) or in iTerm it brings up menus...

@MatCyg
Copy link

MatCyg commented Mar 28, 2022

Sorry, I misunderstood. I don't think you can do it with mod morph, but it is fairly easy with a macro. An idea is to switch to normal alpha layer without auto shift when you press CMD. This way you do it for all your keys, not only copy/paste.

ZMK_MACRO(cmdAlpha,
    wait-ms = <0>;
    tap-ms = <0>;
    bindings
        = <&macro_press &mo ALPHA &kp LGUI>,
          <&macro_pause_for_release>,
          <&macro_release &mo ALPHA &kp LGUI> ;
)

@Vasilis
Copy link
Author

Vasilis commented Apr 6, 2022

Thank you, @MatCyg ! Will try it out!

@elismaga
Copy link

Did this work? I don't quite understand how that solution works or how to implement it.
In QMK the default behavior is what I am looking for which is what the OP described. In order to get the default behavior of ZMK you have to enable AUTO_SHIFT_MODIFIERS. I was hoping ZMK had a setting like this to reverse the default behavior.
AUTO_SHIFT_MODIFIERS

@elismaga
Copy link

@MatCyg What if you set "hold-trigger-key-positions" to an empty array in your auto shift definition?

@feerrenrut
Copy link

@elismaga I think the suggestion looks like this: feerrenrut/ergodox-zmk-config@e75d0ce

One issue is that a macro needs to be created for each mod key that used. I'll need separate macros for each of the following:

  1. left control
  2. right control
  3. left shift
  4. right shift
  5. left meta
  6. left alt
  7. right alt

It would be nice if a macro accepted arguments, then you could make a macro to use like NO_AUTO_SHIFT(TO_LAYER, LCTRL)

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

No branches or pull requests

4 participants