How to Create Custom Keyboard Shortcuts for Raspberry Pi

(Image credit: Chalitsa Hongtong / Shutterstock)
Latest Videos FromTom's Hardware
Avram Piltch
Managing Editor: Special Projects

Avram Piltch is Managing Editor: Special Projects. When he's not playing with the latest gadgets at work or putting on VR helmets at trade shows, you'll find him rooting his phone, taking apart his PC, or coding plugins. With his technical knowledge and passion for testing, Avram developed many real-world benchmarks, including our laptop battery test.

  • jordantsap
    I changed the shortcuts exactly as you said but after reboot the old shortcuts are working
    Reply
  • Barry_IA
    jordantsap: Some things to try –



    At the top of /etc/xdg/openbox/lxde-pi-rc.xml it says not to modify that file (in that location) but to copy it to $HOME/.config/openbox, so:

    At your home directory (/home/pi or whatever)

    cd .config (notice the leading dot – it’s a hidden directory)

    sudo mkdir openbox (I needed to create this subdir on my RPi 400)

    cd openbox

    sudo cp /etc/xdg/openbox/lxde-pi-rc.xml lxde-pi-rc.xml



    You should now be able to ls $HOME/.config/openbox/lxde-pi-rc.xml and see the working copy there.



    sudo nano $HOME/.config/openbox/lxde-pi-rc.xml to edit.



    Some caveats:

    Watch your indent spacing; don’t tab – copy a section and edit it might be easier.



    If your new text is red it’s in the wrong section. I originally put my keybinding at the end of the file so I could find it easier. Found out later the end is commented for examples.



    So I put my keybinding in, rebooted so it would take effect, and it worked. Yeah! Oddly when I brought it up from a cold boot it didn’t – did a different function. Found out this other function was listed later so it was overwriting mine; no idea why it worked right the other day. I commented the ‘duplicate’ – the ‘#’ does not work for this filetype; at the beginning of the section you need <!-- and at the end --> . (Hopefully still works tomorrow!!)
    Reply