TransWikia.com

How to setup in xkb caps lock to vim keys and to regular Caps at the same time?

Unix & Linux Asked on December 17, 2021

I’m currently using the Caps key as ISO_Level3_shift and I’m mapping the h,j,k,l,$ and 0 to vim keys. It works and everything is fine. However, I use SQL and I want to write all the code for SQL in capital letters so it would be hard to press the shift key while typing every letter. So, what I want is someway of using this vim keys as is, but also having the ability to toggle Caps lock when doing some SQL programming. maybe something like holding it for a while or pressing shift+caps to toggle it back.

I’m using XKB to achieve what I’m doing as xmodmap doesn’t work for me as I use a second layout which will not work correctly if I use xmodmap.

Here is my /usr/share/X11/xkb/symbols/us file – or at least part of it where I set my current setup:

    key <AC06> {    [     h,    H,  Left        ]   };
    key <AC07> {    [     j,    J,  Down        ]   };
    key <AC08> {    [     k,    K,  Up      ]   };
    key <AC09> {    [     l,    L,  Right       ]   };
    key <AE10> {    [     0,    parenright, Home    ]   };
    key <AE04> {    [     4,    dollar, End     ]   };
    key <CAPS> {    [  ISO_Level3_Shift             ]       };

this portion is inside the

default  partial alphanumeric_keys modifier_keys
xkb_symbols "basic" {}

block

Thanks in advance for your help.

One Answer

You can achieve this with one of these commands:

Swap esc with caps: setxkbmap -option caps:swapescape

Shift + caps turn on capslock: setxkbmap -option caps:escape_shifted_capslock

Just run one of them at startup, you can add it to your ~/.xprofile

source: man xkeyboard-config & man setxkbmap

Answered by user419050 on December 17, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP