rvaiya / keyd

A key remapping daemon for linux.
MIT License
2.89k stars 171 forks source link

More configuration examples please? #132

Closed dit7ya closed 2 years ago

dit7ya commented 2 years ago

Hi, Thanks for this amazing project. I would love to see more configuration examples with more complex setups.

For example, I am not sure how to achieve the following.

With the following config


[main]
leftmeta = overload(M, M-f12)
space = overload(extend, space)

[extend]

h = left
j = down
k = up
l = right
m = enter
; = backspace
leftmeta = leftmeta

space-meta-m is interpreted as meta-enter but meta-space-m just becomes enter - while I would them both to be meta-enter. I have tried adding a space = overload(extend, space) to the [meta] layer without any results.

Also, what is a good timing delay to use for a key like space?

dit7ya commented 2 years ago

Also, suppose I inherit a layer like the following


[extend:A]

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

I am noticing the behavior for alt + h/j/k/l is different than if I do not inherit it - this becomes clear when trying to use these in a program like Firefox - seems like some conflicts are happening . I am wondering how can I replace a modifier layer's some keys without removing the behavior of the rest of them from the main layer.

rvaiya commented 2 years ago

Thanks, I've been meaning to improve the documentation and provide more examples (PRs welcome :P).

space-meta-m is interpreted as meta-enter but meta-space-m just becomes enter - while I would them both to be meta-enter. I have tried adding a space = overload(extend, space) to the [meta] layer without any results.

The key thing to remember is that modifiers are just layers, and that defining one activation path (e.g space-meta-m) is not sufficient if you want to achieve symmetry. You also have to explicitly define meta-space if your goal is to have the two sequences behave identicaly.

In order to achieve the end you have in mind you probably want something like:

[main]

meta = overload(meta, M-f12)
space = overload(extend, space)

[meta]

space = layer(meta)

[extend]

meta = layer(meta)

Also, what is a good timing delay to use for a key like space?

I've found this varies by keyboard and typing style. In general, I advise against timeout based overloading (see #34) but if you must use it, then I've personally found somewhere in the range 100-300 ms to work best.

Also, suppose I inherit a layer like the following ... I am noticing the behavior for alt + h/j/k/l is different than if I do not inherit it.

The only difference is that extend:A will cause alt to be depressed whenever the layer is active. Whenever a layer entry is activated alt will temporarily be released and the defined key sequence will be sent (you can verify this using keyd -m).

Unfortunately this seems to cause some programs (e.g firefox) to activate the menu since they interpret alt by itself. There is a hack to get around this by interposing an additional control sequence using macros (see #128).

You are the second person to observe this, so I am considering changing the default behaviour to do this automatically.

rvaiya commented 2 years ago

The alt issue has now been fixed. It should work out of the box in the latest commit.

rvaiya commented 2 years ago

I am closing this for now, but feel free to reopen it if you feel your issue remains unaddressed.