Ubuntu – How to bind Alt+Arrows to PageUp/PageDown

key-binding

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.

Best Answer

  • 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.

  • Related Question