You are not logged in.
**Title:** Issue with Mapping Caps_Lock to Escape Key in Vim
**Body:**
Hello Arch Linux community, I'm a complete newbie to arch ;-;
I'm trying to remap the Caps_Lock key to function as an Escape key to improve my navigation in Vim. I don't really need the Caps_Lock key anymore, so i didn't swap the keys.
The `.Xmodmap` file is really basic:
```
keycode 66 = Escape NoSymbol Escape NoSymbol
```
However, I'm experiencing an issue where the Caps_Lock key sometimes behaves as if it's both Escape and Caps_Lock. To diagnose the problem, I used the following command to print the keypresses in a more readable format:
```
xev | awk -F'[ )]+' '/^KeyPress/ { a[NR+2] } NR in a { printf "%-3s %s\n", $5, $8 }'
```
The output I get is inconsistent and sometimes shows the Caps_Lock key as Escape:
```
38 a
66 Escape
38 A
66 Escape
38 a
9 Escape
38 a
9 Escape
38 a
```
Interestingly, the problem seems to resolve itself after a re-login (sometimes) , but manually running `xmodmap .Xmodmap` during a session doesn't fix the issue.
I'm not sure what's causing this behavior, and I could use some help diagnosing the problem. Any suggestions or insights would be greatly appreciated.
Thank you!
Offline
That's the wrong approach. Just `setxkbmap -option caps:escape`, or prior to starting X `export XKB_DEFAULT_OPTIONS=caps:escape`.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Or https://wiki.archlinux.org/title/Xorg/K … tion_files
nb. that setxkbmap is transient and will get lost when the keyboard (logically) re-attaches what can happen in response to an S3 cycle or USB autosuspend (let alone the hardware specific issues of wireless keyboards) so I'd opt for the environment or the config file.
Offline
Sorry for the delayed reply..
That's the wrong approach. Just `setxkbmap -option caps:escape`, or prior to starting X `export XKB_DEFAULT_OPTIONS=caps:escape`.
Thank you this worked!
I'm curious if it's possible to configure the Caps Lock key to act as Escape when tapped and as Left Ctrl when held down. I understand this might not be essential, but I'm exploring my options.
Thank you for your guidance.
Offline
Or https://wiki.archlinux.org/title/Xorg/K … tion_files
nb. that setxkbmap is transient and will get lost when the keyboard (logically) re-attaches what can happen in response to an S3 cycle or USB autosuspend (let alone the hardware specific issues of wireless keyboards) so I'd opt for the environment or the config file.
Thanks for your suggestion! Those sounds like really advanced topics.. especially for a noob like me..
If i use setxkbmap, the caps_lock key stops working if I open neovim? But if I set the environment variable, this bug doesn't occur. I don't really understand why this is the case but I guess I'll be sticking to the second option.
Last edited by hat082 (2024-06-11 07:45:54)
Offline
I'm curious if it's possible to configure the Caps Lock key to act as Escape when tapped and as Left Ctrl when held down.
Not through xkb settings, no. The available options can be found in `man xkeyboard-config`; the most relevant options are under the OPTIONS section "Caps Lock behavior" subsection.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
For different behavior on "empty" release of a modifier (ctrl) you'd need a shortcut deamon that can discrimintate that way (i think xbindkeys can via the release modifier, but would have to test that) and then bind that action to a shortcut that fires "xdotool key escape" or so.
Offline