How to create custom shortcut keys for Raspberry Pi

In Windows, it's easy to use custom keystrokes to open your favorite apps, but in Raspbian, the official operating system of the Raspberry Pi, the process is a bit more complicated.

Every keystroke or mouse movement is very important. But if you can, for example, press CTRL+ ALT+ Cto launch Chrome instead of hovering on the screen and click on the icon, why not do that?

In Windows, it's easy to use custom keystrokes to open your favorite apps, but in Raspbian, the official operating system of the Raspberry Pi, the process is a bit more complicated. The following article will show you how to create custom shortcuts for your Raspberry Pi.

Note: Remember that these shortcuts only work on the Raspbian desktop. If you are booting into the Command Prompt or logging into the Command Prompt via SSH, these shortcuts will not work.

1. Navigate to the Command Prompt. You can get there by clicking CTRL+ ALT+ Tfrom your desktop, click the icon Terminal , connecting via SSH or boot into the Command Prompt.

2. Open the file /etc/xdg/openbox/lxde-pi-rc.xml to edit by importing.

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

3. Scroll down to the section . You can also get there by pressing CTRL+ Wto search and type at the prompt. If you look around the section, you will see all of the built-in keyboard shortcuts for the Raspberry Pi listed. For example, the code that specifies ALT+ F4as a combination to close a window is in this block.

Picture 1 of How to create custom shortcut keys for Raspberry Pi
All keyboard shortcuts are integrated into the keyboard of the Raspberry Pi

4. Enter a comment tag, such as below a tag . This step is not strictly necessary, but it is very useful to find shortcuts later.

Picture 2 of How to create custom shortcut keys for Raspberry Pi
Enter tag comment

5. Enter the following keybind code (link key) below the comment tag.

[LAUNCH COMMAND]

Obviously, you need to replace [KEYBOARD COMBO] with an actual key set and [LAUNCH COMMAND] with the command you need to start the application. This is an example of the Chromium browser launches when you press CTRL+ ALT+ c.

chromium-browser

6. Save the file and reboot. Your shortcut will now work.

Name of the key link

Key combinations must be a combination of keys and hyphens separating them. For example, the CSA will be CTRL+ SHIFT+ aand A-F2 will be ALT+ F2. Special keys such as CTRLand ALThave abbreviations. Here is a list of abbreviations for special keys:

  1. A - ALT
  2. C - CTRL
  3. S - Shift
  4. W - Windows key
  5. Print - Print Screen
  6. Up / Down / Right / Left - Arrow keys
  7. Prior - Pg Up
  8. Next - Pg Dn
  9. space - Spacebar
  10. Home - Home
  11. End - End
  12. Return - Enter
  13. BackSpace - Backspace

If there are any other keys on the keyboard (an additional function key, etc.), you can find out what the system calls them by opening a Terminal window (from the Raspbian desktop) and typing xev -event keyboardat the prompt. . Then you will see the names of every key you press in a format like this.

Picture 3 of How to create custom shortcut keys for Raspberry Pi
Output xev when pressing the Enter key

The screenshot above shows the output when pressing the key Enter, at least for the laptop used for this article. You can see that it is named "Return" and also provides the hexcode 0xff0d. You can use a hexcode in XML. So CTRL+ ALT+ Enterwill be CA-Return or CA-0xff0d.

The commands

To start a program, you need to know its execution command, which is the command you will use if you want to launch it directly from the Terminal window. You can find these commands for any installed program, by right-clicking its icon in the Start menu and selecting Properties , then viewing the Command field on the Desktop Entry tab .

You can often omit the additional arguments after the command, so chromium-browser still works and practically does not require % U in the keybind XML. An exception is the Gnome Screenshot app, which must be launched as "gnome-screenshot --interactive".

Picture 4 of How to create custom shortcut keys for Raspberry Pi
The chromium-browser command launches Chromium

You can test any command by typing it into a Terminal window. Also, sometimes there is a simpler command shown here. For example, you can start the GIMP image editor with the " gimp " command, but the command shown in the Properties box is " gimp-2.10 ". Both are active.

This is a list of commands for common applications.

  1. chromium-browser - Chromium
  2. Geany - Geany
  3. scratch3 - Scratch 3
  4. gimp - GIMP
  5. vlc - VLC
  6. pcmanfm - File Manager
  7. lxterminal - Terminal
  8. galculator - Calculator
  9. gnome-screenshot --interactive - Gnome Screenshot

Act

To launch the program, the most common reason for creating shortcuts, you will always use "Execute" as the action. But there are a few other actions you can use to manipulate elements of the Raspbian desktop user interface or its windows. There is a complete list of actions at the Openbox website (Openbox is the window manager that Raspbian uses by default). Here are some common actions:

  1. Execute - The main and probably the only action you'll need for keyboard macros.
  2. ToggleFullScreen - Makes the window full screen. This action has been assigned to ALT + F11.
  3. Close - Closes the window, assigned to ALT + F4 .
  4. Iconify - Minimize the window.
  5. ToggleMaximize - Maximize or maximize the window.
  6. NextWindow - Go to the next window, assigned to ALT + TAB.
  7. PrevWindow - Go to the previous window, assigned to ALT + SHIFT + TAB.

Some actions also have sub options. For example, NextWindow has an option called allDesktops , which lets you choose whether you will cycle through windows on all desktops (assuming you have more than one) or just an existing desktop. The Openbox website has details of all the options. Reference at:

http://openbox.org/wiki/Help:Actions
Update 10 July 2020
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile