Ubuntu – xkb mapping of R_Control+Arrows

17.10keyboard-layoutxkb

Have a laptop with directional Arrow keys and Fn + Arrows for PageUp/PageDown/Home/End. Want to make those keys such that the Right Control changes them to:

  • RCtrl + Up -> Page Up
  • RCtrl + Down -> Page Down
  • RCtrl + Left -> Ctrl + Page Up
  • RCtrl + Right -> Ctrl + Page Down

Left control should continue to work as before.

XKB that is close to working:

The following content is saved to /usr/share/X11/xkb/symbols/custom and loaded via this command setxkbmap -symbols "pc+us+inet(evdev)+custom":

key <UP> {  
    type= "PC_CONTROL_LEVEL2",  
    symbols[Group1]= [ Up, NoSymbol ],  
    actions[Group1] = [NoAction(), RedirectKey(key=<PGUP>, clearMods=Control)] };  
key <DOWN> {  
    type= "PC_CONTROL_LEVEL2",  
    symbols[Group1]= [ Down, NoSymbol ],  
    actions[Group1] = [NoAction(), RedirectKey(key=<PGDN>, clearMods=Control)] };  
key <LEFT> {  
    type= "PC_CONTROL_LEVEL2",  
    symbols[Group1]=  [ Left, NoSymbol ],  
    actions[Group1] = [NoAction(), RedirectKey(key=<PGUP>)] };  
key <RGHT> {   
    type= "PC_CONTROL_LEVEL2",  
    symbols[Group1]= [ Right, NoSymbol ],  
    actions[Group1] = [NoAction(), RedirectKey(key=<PGDN>)] };

The Problem:

Unfortunately the script above captures both Control keys, not only the right one. I need the left Control key to not change it's behavior. Changing the PC_CONTROL_LEVEL2 -> PC_RCONTROL_LEVEL2 looks like it should work, but nothing works differently in that case (as if I hadn't made any changes).

Any ideas why PC_RCONTROL_LEVEL2 doesn't do anything?

I have tried bumbling around all sorts of different things, but unfortunately nothing has worked. I can't even seem to keep the right control key from acting as a control key, even after trying to map it directly to another key.

I am currently running Ubuntu 17.10 w/ the default GNOME interface. Thanks!

Best Answer

You need to add a function wrapper as follows.

default  partial alphanumeric_keys modifier_keys
xkb_symbols "custom" {

key <UP> {  
    type= "PC_CONTROL_LEVEL2",  
    symbols[Group1]= [ Up, NoSymbol ],  
    actions[Group1] = [NoAction(), RedirectKey(key=<PGUP>, clearMods=Control)] };  
key <DOWN> {  
    type= "PC_CONTROL_LEVEL2",  
    symbols[Group1]= [ Down, NoSymbol ],  
    actions[Group1] = [NoAction(), RedirectKey(key=<PGDN>, clearMods=Control)] };  
key <LEFT> {  
    type= "PC_CONTROL_LEVEL2",  
    symbols[Group1]=  [ Left, NoSymbol ],  
    actions[Group1] = [NoAction(), RedirectKey(key=<PGUP>)] };  
key <RGHT> {   
    type= "PC_CONTROL_LEVEL2",  
    symbols[Group1]= [ Right, NoSymbol ],  
    actions[Group1] = [NoAction(), RedirectKey(key=<PGDN>)] };
};