rvaiya / keyd

A key remapping daemon for linux.
MIT License
2.88k stars 170 forks source link

Vim Navigation AND Hyperkey? #370

Closed liberninja closed 1 year ago

liberninja commented 1 year ago

I've got this config right now for basic vim navigation using capslock, and escape when tapped:

[ids]
*
[main]

capslock = overload(capslock_layer, esc)

[capslock_layer]
h = left
j = down
k = up
l = right

Is there a way I can also use capslock as a hyper key for using keyboard shortcuts? I used to use xmodmap to assign caps to Hyper_L and map it to the mod3 slot and it worked great, but I can't figure out how to get the best of both worlds. Any suggestions?

nsbgn commented 1 year ago

If I recall correctly, the Hyper key itself is an X11 concept (someone correct me if I'm wrong), so you will need the help of something like xmodmap if that exact behaviour is important. However, you can attach modifiers to all non-bound keys in your layer by using something like [capslock_layer:M] or [capslock_layer:M-C], (M is the Super key, C is control etc). You can bind keyboard shortcuts accordingly. Does that help?

herrsimon commented 1 year ago

A general remark: It is almost certainly much simpler and cleaner to completely get rid of any remapping in X and do everything in keyd.

If you have some hotkey daemon with shortcuts bound to hyper+<key>, just replace hyper by some key not physically present on a typical keyboard (such as f13) and then use f13+<key>.

If your shortcuts are just key combinations, you can directly put these on your capslock_layer.

If you want a mixture, have some keys on the capslock_layer send f13+<key>, which is then processed by your hotkey daemon.

liberninja commented 1 year ago

Think I figured out a solution, although there's probably a better way to do it. Just remapped all the keys (aside from h,j,k,l for navigation) to shift-ctrl-meta-alt+ so now I can use caps+key for whatever keybindings I need 👍 Please let me know if there's a more elegant wayt to do it 🤣

capslock = overload(capslock_layer, esc)

[capslock_layer]
h = left
j = down
k = up
l = right
a = C-S-A-M-a
b = C-S-A-M-b
c = C-S-A-M-c
d = C-S-A-M-d
e = C-S-A-M-e
f = C-S-A-M-f
g = C-S-A-M-g
i = C-S-A-M-i
m = C-S-A-M-m
n = C-S-A-M-n
o = C-S-A-M-o
p = C-S-A-M-p
q = C-S-A-M-q
r = C-S-A-M-r
s = C-S-A-M-s
t = C-S-A-M-t
u = C-S-A-M-u
v = C-S-A-M-v
w = C-S-A-M-w
x = C-S-A-M-x
y = C-S-A-M-y
z = C-S-A-M-z
` = C-S-A-M-`
0 = C-S-A-M-0
1 = C-S-A-M-1
2 = C-S-A-M-2
3 = C-S-A-M-3
4 = C-S-A-M-4
5 = C-S-A-M-5
6 = C-S-A-M-6
7 = C-S-A-M-7
8 = C-S-A-M-8
9 = C-S-A-M-9
f1 = C-S-A-M-f1
f2 = C-S-A-M-f2
f3 = C-S-A-M-f3
f4 = C-S-A-M-f4
f5 = C-S-A-M-f5
f6 = C-S-A-M-f6
f7 = C-S-A-M-f7
f8 = C-S-A-M-f8
f9 = C-S-A-M-f9
f10 = C-S-A-M-f10
f11 = C-S-A-M-f11
f12 = C-S-A-M-f12
- = C-S-A-M--
= = C-S-A-M-=
[ = C-S-A-M-[
] = C-S-A-M-]
\ = C-S-A-M-\
; = C-S-A-M-;
' = C-S-A-M-'
, = C-S-A-M-,
. = C-S-A-M-.
/ = C-S-A-M-/
nsbgn commented 1 year ago

Glad it works. The more elegant way is this:

capslock = overload(capslock_layer, esc)

[capslock_layer:C-S-A-M]
h = left
j = down
k = up
l = right
liberninja commented 1 year ago

Glad it works. The more elegant way is this:

capslock = overload(capslock_layer, esc)

[capslock_layer:C-S-A-M]
h = left
j = down
k = up
l = right

Thank you! That does work, however I notice that the escape is a bit more sluggish with this. Looking at xev output it's doing all four modifiers before the escape key. I'll probably just stick with what I have 👍

64  Alt_L
50  Shift_L
133 Super_L
37  Control_L
9   Escape
svonjoi commented 11 months ago

If you have some hotkey daemon with shortcuts bound to hyper+<key>, just replace hyper by some key not physically present on a typical keyboard (such as f13) and then use f13+<key>.

For example in i3 configuration this does not work i think cuz in key combinations it reqiuires a modifier