jbensmann / mouseless

A replacement for the mouse in Linux
MIT License
183 stars 17 forks source link

Map Caplock to Ctrl With ctrl+h, j, k, l` to Move Cursors #17

Closed czhang03 closed 1 year ago

czhang03 commented 1 year ago

Hi, I am very sorry to post a personal setup issue in the issues, but I am at my wit's end here.

Presonally I use caplock as leftctrl, and use capslock+h, j, k, l to move my cursors.

The problem with that setup is that I think of a good setup to do this. Because caplock is performing two different functionality here, the first is toggling the arrows layer, and the second is to act as ctrl.

I have tried to use capslock: multi toggle-layer arrows; leftctrl, but this means if I press capslock+j it would send ctrl+down instead of down.

Is there any fix to let capslock+h, j, k, l to move my cursors and for everything else use caplock as leftctrl?

jbensmann commented 1 year ago

Hi, it's totally fine to ask setup questions, like this I can see how other people use the software and how it can be improved. And for this one I actually don't think there is an easy way to do it. One could map capslock to only toggle the layer (capslock: toggle-layer arrows) and in that layer map all keys other than h,j,k,l to ctrl plus that key (e.g. a: leftctrl+a).

But since this might be a common use case I am thinking how the configuration format could be extended to make it easier, maybe one could add a parameter passThroughModifiers to the layers which get activated only when a key is not mapped in that layer. Let me know if you have another suggestion.

I03D commented 1 year ago

Now that there is a feature of nested layers, it is possible to implement it.

Let caps lock launch the "caps lock" layer, but so far it does not send "ctrl". Describe all the letters and numbers on the keyboard: x: rightctrl+x. Now you can replace e. g. j: leftctrl+j to j: up.

- name: initial
    passThrough: true
    bindings:
        # ...
        capslock: toggle-layer caps

- name: caps
    passThrough: false
    bindings:
        a: rightctrl+a
        b: rightctrl+b
        # ...

        j: down
        k: up
        h: left
        l: right

But I would advise using more "strict" keys, the shortcuts of which it is not a pity to replace. Because from now on you will not be able to send leftctrl+j to any application.

For example, I use alt+ -qwer for arrows. Besides, having fully described alt, we can stop sending it. This is convenient because accidentally pressing alt opened some unnecessary menu (lipreoffice, m$ word etc).

Now, to still send alt, I press alt+space. (alt+o = alt+space+o)

- name: initial
    passThrough: true
    bindings:
        leftalt: toggle-layer alt
        rightalt: toggle-layer alt

- name: alt
    passThrough: false
    bindings:
        a: rightalt+a
        # ... A giant description of all the desired shortcuts, including the previous system ones (you can't do without it with passThrough:false) ...

        e: down
        w: up
        q: right
        r: left

        space: multi leftalt; layer alt-origin

- name: alt-origin
    passThrough:true
    # By default, you can exit this layer by pressing esc.
jbensmann commented 1 year ago

@I03D your first solution is exactly what I meant, and it should have already worked before since there are no nested layers :)

I left this issue open because I would like a simpler solution, where one does not need to write out every single letter. One thing I want to try is a fallback mapping like _: leftctrl+_, which is used when a key is pressed that is not mapped, that would also be more flexible than the idea with the passThroughModifiers.

jbensmann commented 1 year ago

I have now added the _: leftctrl+_ solution, it will come in the next release.