Ubuntu – How to map Super + UpArrow to PageUp

keyboardkeyboard-layoutshortcut-keys

I'd like to map

  • Super + UpArrow to PageUp

  • Super + DownArrow to PageDown

  • Super + Left to Home

  • Super + Right to End

on an Apple aluminum wireless keyboard. Those who know the keyboard would note that it already does these with the Fn key by default; that's fine, and I'd like to keep that, but be able to do the same with a one-handed key combination as well, hence my wanting the Super mappings.

I've been searching around for a possible way to do this via xmodmap for 3 hours, yet nothing has worked.

Best Answer

try editing your /usr/share/X11/xkb/symbols/pc keyboard definition

(this will change your bindings globally, if you want something more fine tuned, there is some more work to do, like creating a custom keymap or a custom variant)

as you can see here:

key  {        [  Prior                ]       };
key  {        [  Next                 ]       };

as you can see the key PGUP is bound to "Prior". While:

 key  {        [  Left                 ]       };
 key  {        [  Down                 ]       };

LEFT and DOWN keys are bound to "Left" and "Down".

The part between brackets [ ] is a list of symbols to be generated. You can put more than one. The first one is the symbol associated with the unmodified key, while other positions are for symbols associated with the key + some modifier.

Commonly it's used to define the behavior of the key plus the "SHIFT" modifier:

  key  {        [         l,    L               ]       };
  key  {        [ semicolon,    colon           ]       };

But also other modifiers can be specified, for example in the esperanto map (epo):

  key   { [ jcircumflex,  Jcircumflex,  bracketleft,   braceleft  ] };
  key   { [ hcircumflex,  Hcircumflex,  bracketright,  braceright ] };

you can type a [ character by typing AltGr + key (the [ key on the us keymap), and { by Shift+AltGr + key .

So far so good. The sequence we can understand from looking at some simple examples is:

plain shift altgr shift+altgr


However, we want to be able to bind our LEFT and RIGHT key to the plain and CTRL+ALT modifiers. How to achieve that?

I have no idea, and never tried, but I'd take inspiration from /usr/share/X11/xkb/symbols/pc:

xkb_symbols "function" {
    key  {
        type="CTRL+ALT",
        symbols[Group1]= [ F1,  XF86_Switch_VT_1 ]
    };

Perhaps we can do the same thing for our arrow keys. Let's try to add the following lines:

 key  { type="CTRL+ALT", symbols[Group1]= [  Left, Prior                ]       };
 key  { type="CTRL+ALT", symbols[Group1]= [  Down, Next                 ]       };

Just below the original definitions of LEFT and DOWN, in the bottom part of the 'pc' file.

And then restart the X server. Sorry, but I cannot close my session right now to test it.

BTW, you might be interested in http://code.google.com/p/partiwm/wiki/xpra, so that you can restart the X session and still preserve some applications across restarts.

Related Question