keyd icon indicating copy to clipboard operation
keyd copied to clipboard

Capslock as escape doesn't work 'properly' in Neovim/Helix etc.

Open codeRSH opened this issue 10 months ago • 5 comments

First thank you for this fantastic piece of software. Also I apologize if this has already been addressed before. I searched but couldn't find an exact solution.

My keyd config.

[ids]

*

[main]

# Maps capslock to escape when pressed and control when held.
capslock = overload(control, esc)

# Remaps the contro + escape key to capslock
[control]
esc = capslock

My issues

Capslock overloading doesn't work properly. I haven't faced any issues while using Capslock as control, but using Capslock as Escape inside editors like Neovim have been a hit and a miss affair.

I sometimes have to press Capslock multiple times for it to detect as an 'escape' key. But other times it detects it in only one keypress.

I have checked this in multiple Terminal (Gnome's stock terminal, Konsole, Wezterm etc.). and multiple editors (like Neovim and Helix) and also within multiple desktop environments (Gnome and KDE).

I am running Fedora 41.

codeRSH avatar Feb 19 '25 10:02 codeRSH

Can you show an example output of keyd monitor -t to demonstrate the issue?

Overloading can be tricky --- if you type so fast that the capslock's keyup has not occurred before the next key's keydown, keyd disambiguates it to a control rather than an escape. If that is what is going on here, overloadt, overloadt2 and overloadi/lettermod could potentially remedy it. But that is assuming that that is indeed your issue.

nsbgn avatar Feb 19 '25 22:02 nsbgn

This is what I am getting while running keyd monitor -t.

Image

And you are probably right, this usually happens while I am writing long pieces of text inside neovim and have to press capslock suddenly in the middle of the writing session.

I do not know how to use overloadt, overloadt2 etc. Is there any example which can help?

codeRSH avatar Feb 20 '25 04:02 codeRSH

I have same problem. I don't think it was like this before.

I checked in monitor and pressing caps results in :

keyd virtual keyboard	0fac:0ade:efba1ddf	leftcontrol down
keyd virtual keyboard	0fac:0ade:efba1ddf	leftcontrol up
keyd virtual keyboard	0fac:0ade:efba1ddf	esc down
keyd virtual keyboard	0fac:0ade:efba1ddf	esc up

Is this intended?

And, keyd changes both left ctrl and right control to left control.

error404seeker avatar Feb 20 '25 08:02 error404seeker

@codeRSH You need to run it using sudo.

this usually happens while I am writing long pieces of text inside neovim and have to press capslock suddenly in the middle of the writing session.

You are probably unconsciously pressing another key before the capslock up event. You can verify this with sudo keyd monitor -t.

Try 'capslock=overloadt(control, esc, 100). It will mitigate these sort of event ordering issues at the expense of requiring you to hold the key for at least 100ms (adjust to taste). Overloading can be quite tricky and involves different trade offs. See the man page for more options.

@error404seeker

I checked in monitor and pressing caps results in : [...] Is this intended?

Yes, this is by design. It allows you to do things like control click with unmanaged mice. It shouldn't be an issue in practice since most applications don't do anything when control is tapped (if they do, you need to use one of the time based overload options).

I have same problem. I don't think it was like this before.

Can you elaborate? Which version behaves differently? Annotated keyd monitor output whilst reproducing the issue would also be useful.

rvaiya avatar Feb 21 '25 01:02 rvaiya

@rvaiya It is working properly in Neovim. Not so sure whether it was my problem or sth. I should have properly checked it with keyd monitor but I had attributed it to extra left control press back then.

error404seeker avatar Feb 21 '25 04:02 error404seeker