5

I'm considering getting a 60% keyboard and want to try out working with that layout before buying the actual keyboard.

I'm trying to map arrow keys to caps lock + ijkl and disable the real arrow keys. I've found out how to remap it, but when I try to disable the real arrow keys, the remapped ones break. Here's a working map:

keycode 66 = Mode_switch
keycode 31 = i I Up
keycode 44 = j J Left
keycode 45 = k K Down
keycode 46 = l L Right

To disable arrow up I add

keycode 111 =

And as soon as I do that, ijkl don't work as characters anymore, but act as arrows even without pressing the modifier(caps lock). How do I disable the arrow keys without breaking my previous mapping?

  • Does it work for you if you disable it manually? via $ xmodmap -e 'keycode 111=' – tukan Feb 27 '18 at 9:51
  • It works the same as with the config file. I can either disable the key, or remap it, but not both. – Tomas Feb 28 '18 at 10:14
  • Hmm that is weird. Anyways why you are trying to disable the arrow keys anyways? If you will have 60% keyboard you won't have them. If you don't have them you don't have to disable them, isn't that so? Just enter the working mapping and you are fine. – tukan Feb 28 '18 at 12:40
  • I have found a github xmodmap for such keyboards. You can try it out. gist.github.com/jeffeb3/743507871082c9e1ca44 – tukan Feb 28 '18 at 12:42
  • I forget that I have the remapping and continue to use the arrow keys out of habit. I want to disable the arrow keys to remind myself that remapping exists and I should use it. I've checked the config on Github, it doesn't seem to disable any keys, so I doubt it would be useful. – Tomas Mar 1 '18 at 7:22
2
+25

After reading in and getting some information around. It appears that the issue is that you have to delete the modifiers before actually doing the remapping.

To the answer :

After changing the settings my xmodmap looks like:

xmodmap: up to 4 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0x32),  Shift_R (0x3e)
lock      
control     Control_L (0x25),  Control_R (0x69)
mod1        Alt_L (0x40),  Alt_R (0x6c),  Alt_L (0xcc),  Meta_L (0xcd)
mod2        Num_Lock (0x4d)
mod3        Mode_switch (0x42),  Mode_switch (0xcb)
mod4        Super_L (0x85),  Super_R (0x86),  Super_L (0xce)
mod5      

Investigation of Mode_switch brings us to the conclusion that Caps_Lock has been successfully mapped:

[smalltalk@localhost ~]$ xmodmap -pke | egrep -e '(Mode_switch)'
keycode  66 = Mode_switch NoSymbol Mode_switch
keycode 203 = Mode_switch NoSymbol Mode_switch

Now xmodmap the excerpt from the man pages:

       keycode NUMBER = KEYSYMNAME ...
               The list of keysyms is assigned to the indicated keycode (which
               may be specified in decimal, hex or octal and can be determined
               by running the xev  program).   Up  to  eight  keysyms  may  be
               attached  to  a  key, however the last four are not used in any
               major X server implementation.  The first keysym is  used  when
               no  modifier  key  is pressed in conjunction with this key, the
               second with Shift, the third when the Mode_switch key  is  used
               with  this  key  and  the  fourth when both the Mode_switch and
               Shift keys are used.

The following configuration works but you have to hold Caps_Lock while using the i,j,k,l (exactly as written in the man pages):

Edit vim ~/.Xmodmap:

! make Capslock the "Mode_switch" key
clear Lock

! All Mod must be cleared
clear Mod1
clear Mod2
clear Mod3
clear Mod4
clear Mod5

! clearning current Caps_Lock assigment and assigning it new one
keycode 66 =
keycode 66 = Mode_switch

! setting all the modification keys
add Mod1 = Alt_L Alt_R Meta_L
add Mod2 = Num_Lock
add Mod3 = Mode_switch
add Mod4 = Super_L Super_R Hyper_R

! Clear must be done before configuring it
keycode 31 =
keycode 44 =
keycode 45 =
keycode 46 =

! Configuration (first column normal type, second with shift and second with Mod_switch)
keycode 31 = i I Up
keycode 44 = j J Left
keycode 45 = k K Down
keycode 46 = l L Right

! Clearing the arrow keys and some functional keys like home
keycode 111 =
keycode 113 =
keycode 114 =
keycode 116 =
keycode 112 =
keycode 117 =

Now to the big question:

How to make the i,j,k,l keys work while Caps_Lock on? You will probably have to make changes to xkb, which I have to think over.

Edit

Yes, you can. I have figured it out.

Note: this applies to all keyboards, all layouts, thus is good for testing. If you want to do it via xkb properly you have to create your own layout and have a group1 and group2 + do the mapping.

The bellow is a hack ideal for testing your keyboard(s) (don't forget to backup your ../basic file!):

Warning this applies to all keyboards, all variants.

Edit file: sudo vim /usr/share/X11/xkb/compat/basic

# Add  Caps_Lock to virtual modifiers
    virtual_modifiers  NumLock,AltGr,Caps_Lock;

# change FROM:
    interpret Mode_switch {
        useModMapMods= level1;
        virtualModifier= AltGr;
        action= SetGroup(group=+1);
    };

# TO:
    interpret Mode_switch {
        useModMapMods= level1;
        virtualModifier= Caps_Lock;
        action= LockGroup(group=+1);
    };

# change from
    group 2 = AltGr;
TO:
    group 2 = Caps_Lock;

Note: If you have multiple layout it can interfere with those.

0

Sorry for writing an answer instead of commenting, but I still don't have enough reputation for that. I know that this doesn't answer you question, but it could solve your problem.

Instead of remapping the keys on the OS you might want to buy a keyboard that supports remapping the keys in itself. Especially a keyboard that is supported by the QMK Firmware. You can find a list of all the compatible keyboards here.

With this firmware you can map any key to any action including adding many layers where every key can do different things. Imagine it like pressing the fn key on laptops, except it's fully customizable. You can pick which key activates which layer and even how. For example you can have it toggle the layer on/off, keep it active while holding the key etc. This way you could have Caps Lock be Caps Lock when tapped and switch to another layer (where the ijkl keys are arrow keys) when held down.

The only downside is that remapping requires you to edit arrays in C code, though it's actually pretty simple and requires no prior programming knowledge. The documentation is quite extensive and explains everything you need to get started.

There are many 60% keyboard options, though most are kits which you have to assemble yourself. If you have no problem with that check out the GH60, Satan or XD60 boards. You can find all of those on If you don't want to assemble it yourself, you can check out the Whitefox keyboard or see if you can find something on the KBDFans store as they offer assembling services for most of their kits.

  • As I've mentioned in the question, I'm not sure if I could live without arrow keys so "[I] want to try out working with that layout before buying the actual keyboard." – Tomas Mar 1 '18 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.