12

I just tried it using loadkeys and this map file:

alt keycode 73 = Prior
string Prior = "\033[5~"
alt keycode 81 = Next
string Next = "\033[6~"

But it doesn't work.

6
  • Do you have to use loadkeys?
    – Seth
    Feb 3 '13 at 6:04
  • Turns out loadkeys is for TTYs. We'll have to use xkbcomp also, I'm slowly digging it.
    – int_ua
    Feb 5 '13 at 12:26
  • 1
    What about xbindkeys or xmodmap?
    – Seth
    Feb 5 '13 at 14:57
  • 1
    xbindkeys is excessive for this, xmodmap - yeah, could be :) I'm just working with a xkbcomp dump already.
    – int_ua
    Feb 6 '13 at 6:51
  • But if you'll find a way with xbindkeys it would be ok too, I guess :)
    – int_ua
    Feb 7 '13 at 22:49
10

Install xbindkeys and xte:

sudo apt-get install xbindkeys xautomation

Next we need to find the key mappings for Alt+Arrow.

Run xbindkeys -k and press Alt plus whatever arrow key you want. For Alt+Up Arrow I get:

"NoCommand"
m:0x18 + c:111
Alt+Mod2 + Up

Now that we know what the bindings for our keys are we need to create the .xbindkeys configuration file. Run:

touch .xbindkeysrc
gedit .xbindkeysrc

touch creates the file and gedit opens it. Now add:

"xte 'key Page_Up'"
m:0x18 + c:111
Alt+Mod2 + Up

To the file and save it. This will bind Alt+Up Arrow to PgUp.

The basic syntax for xbindkeys is:

"command to run (in quotes)"
keysym of key

Your complete file should look almost identical to this:

"xte 'key Page_Down'"
m:0x18 + c:116
Alt+Mod2 + Down  

"xte 'key Page_Up'"
m:0x18 + c:111
Alt+Mod2 + Up  

Now add xbindkeys to "Startup Applications" to make it run when you boot your computer.
Click 'Add' and put /usr/bin/xbindkeys in the 'Command' field.

enter image description here

Click 'Add' again and reboot.

7
  • 1
    Doesn't work for me :( Tried both m:0x8 + c:111 (just Alt+Up) and m:0x18 + c:111 and both in Unity and KDE.
    – int_ua
    Feb 9 '13 at 3:47
  • @int_ua Did you get your bindings from xbindkeys -k or did you copy them from my post? You should get your own from xbindkeys -k.
    – Seth
    Feb 9 '13 at 3:49
  • I tried both but now I've used it second time in Unity and it gives different result: m:0x18 + c:64 Edit: no, the same. Had to kill another xbindkeys.
    – int_ua
    Feb 9 '13 at 3:52
  • Does not work for me either. I tried to remap Alt + Left to Home.
    – Rasmus
    Mar 21 '14 at 23:09
  • 1
    @Rasmus That's odd. What is the contents of your .xbindkeysrc? (post it to paste.ubuntu.com so I can look).
    – Seth
    Mar 21 '14 at 23:11
1

I read this https://help.ubuntu.com/community/KeyboardShortcuts which helped me figure out the following. While the xautomation package that includes the xte tool might be used instead of xvkbd to emit the key codes I used xvkbd to do the same thing.

sudo apt-get install xbindkeys xbindkeys-config xvkbd

xbindkeys --defaults > /home/your-user-name/.xbindkeysrc

For some reason this added a binding for ctrl-f that I had to comment out. While perhaps a useful default example I need ctrl-f to find inside of web pages.

After figuring out the "keysims" of Prior for PgUp and Next for PgDown this wasn't too tough. Running and using xbindkeys-config resulted in the following entries in .xbindkeysrc for me.

#alt-up
"xvkbd -xsendevent -text "\[Prior]""
    m:0x18 + c:111
    Alt+Mod2 + Up

#alt-down
"xvkbd -xsendevent -text "\[Next]""
    m:0x18 + c:116
    Alt+Mod2 + Down

when using Ubuntu 12.04 precise pangolin after creating the .xbindkeysrc file it was detected and the xbindkeys program was run automatically on my next login.

The same will work for ctrl.

#ctrl-up
"xvkbd -xsendevent -text "\[Prior]""
    m:0x14 + c:111
    Ctrl+Mod2 + Up

#ctrl-down
"xvkbd -xsendevent -text "\[Next]""
    m:0x14 + c:116
    Ctrl+Mod2 + Down
0

This:

key   <UP> {
    type= "PC_ALT_LEVEL2",
    symbols[Group1]= [           Up,         KP_Prior ]
};
key <DOWN> { 
    type= "PC_ALT_LEVEL2",
    symbols[Group1]= [           Down,         KP_Next ]
};
key <LEFT> {
    type= "PC_ALT_LEVEL2",
    symbols[Group1]= [           Left,         KP_Home ]
};
key <RGHT> {
    type= "PC_ALT_LEVEL2",
    symbols[Group1]= [           Right,         KP_End ]
};

works only in some cases, posting just for reference, it's far from final solution.

P.S. s/KP_//g gives the same result.

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.