6

I've been fumbling with xkbmap for a while, and I can't figure out how to remap the Print Screen button to Home. It's as if the us keymap just doesn't mention the PRSC key code at all. I can't use xmodmap because switching keyboards destroys my configuration.

How can I remap the PrtScr key to Home and the Insert key to End using xkbmap?

PersianGulf
  • 10,850
  • 1
    See Pablo's answer here. The keys defs you're looking for are in /usr/share/X11/xkb/symbols/pc, scroll down to hidden partial alphanumeric_keys and you'll find them. HTH. – don_crissti Jul 10 '15 at 22:43
  • @don_crissti you should post your comment as an answer, it's short to the point and valuable info! – wranvaud Jul 14 '19 at 15:26

1 Answers1

1

I managed to do this by editing my keymap in xkb.

In /usr/share/X11/xkb/symbols/, add this to the file corresponding to the layout you're using (I use an US layout, so I edit the us file):

partial alphanumeric_keys modifier_keys
xkb_symbols "remap_prtsc_home_insert_end" {
    replace key <PRSC> { [ Home ] };
    replace key <INS> { [ End ] };
};

// Then include the previous block in the layout variant you're using // For instance I'm using an international US layout so I edit the "intl" block:

partial alphanumeric_keys xkb_symbols "intl" { include "us(remap_prtsc_home_insert_end)" // ... // Here the rest of your configuration, left unchanged }

Then you need to reboot for these changes to be taken into account.

Warning: double check for typos in these files, as if they are invalid you could have trouble logging in after reboot, and you will need to boot in recovery mode and manually edit the file mentionned above to correct them.


Note on where to find the name of the keys:

On the left hand you need to use the key event names (like <PRSC>), which can be found in /usr/share/X11/xkb/keycodes/evdev.
On the right hand you need to use a valid X11 name for characters (like Home). It seems they can be found in /usr/include/X11/keysymdef.h if you ignore the leading XK_ (not a 100% sure about that, but they seem to match for what I've seen so far).

benterris
  • 191