Skip to content

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

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

Open
codeRSH opened this issue Feb 19, 2025 · 5 comments
Open

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

codeRSH opened this issue Feb 19, 2025 · 5 comments

Comments

@codeRSH
Copy link

codeRSH commented Feb 19, 2025

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.

@nsbgn
Copy link
Collaborator

nsbgn commented Feb 19, 2025

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.

@codeRSH
Copy link
Author

codeRSH commented Feb 20, 2025

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?

@error404seeker
Copy link

error404seeker commented Feb 20, 2025

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.

@rvaiya
Copy link
Owner

rvaiya commented Feb 21, 2025

@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.

@error404seeker
Copy link

@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.

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