7

I recently acquired an old netbook which has no backslash/pipe key. I have successfully remapped the caps lock to backslash using loadkeys.
I would like to map SHIFT+CAPS LOCK to the pipe key in a similar way, in particular not using anything like xkb as I want all this to work on my VTs.

Is it possible to do this using loadkeys or some other tool?

  • I haven't done it before, but [this][1] looks quite encouraging. [1]: stackoverflow.com/questions/3177953/… – Szymon Roziewski Jan 21 '15 at 15:12
  • Thanks, but as far as I can see xmodmap is part of Xorg and will only work within X. I am looking for something to remap keys within a VT. – Alex Jan 21 '15 at 17:31
4

Found my own answer in the keymaps man page. On my keyboard the CAPS LOCK has keycode 41. To remap it, you need the following keymap line,

keycode 41 = backslash bar

This will map CAPS LOCK to the backslash character, and SHIFT + CAPS LOCK to the bar (pipe) character.

  • In what file should that line be put? – Hans Deragon May 26 '18 at 16:03
  • It's a while since I did this so I don't really remember. But check out man keymaps, man dumpkeys and man loadkeys. I think you need to dump the kernel keycode translation tables with dumpkeys, add or update the keymap with the line I gave in the original answer and then use loadkeys to load these keymaps. But, as I said, I may not quite be remembering correctly. – Alex May 26 '18 at 17:53
1

You can use XKB options on the console. See keyboard(5).

XKBOPTIONS="ctrl:nocaps"

in /etc/default/keyboard will make the key to the left of A behave the way it should in X and on text VTs.

Apparently you can use a KMAP=file option in /etc/default/keyboard, to support arbitrary remappings. This would be where you could put keycode 41 = backslash bar, I think.

Run setupcon to apply the change on a text VT.

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.