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
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
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
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
F4as a combination to close a window is in this block.
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.Enter tag comment
5. Enter the following keybind code (link key) below the comment tag.
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
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
aand A-F2 will be
F2. Special keys such as
ALThave abbreviations. Here is a list of abbreviations for special keys:
- A - ALT
- C - CTRL
- S - Shift
- W - Windows key
- Print - Print Screen
- Up / Down / Right / Left - Arrow keys
- Prior - Pg Up
- Next - Pg Dn
- space - Spacebar
- Home - Home
- End - End
- Return - Enter
- 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.
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
Enterwill be CA-Return or CA-0xff0d.
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".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.
- chromium-browser - Chromium
- Geany - Geany
- scratch3 - Scratch 3
- gimp - GIMP
- vlc - VLC
- pcmanfm - File Manager
- lxterminal - Terminal
- galculator - Calculator
- gnome-screenshot --interactive - Gnome Screenshot
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:
- Execute - The main and probably the only action you'll need for keyboard macros.
- ToggleFullScreen - Makes the window full screen. This action has been assigned to ALT + F11.
- Close - Closes the window, assigned to ALT + F4 .
- Iconify - Minimize the window.
- ToggleMaximize - Maximize or maximize the window.
- NextWindow - Go to the next window, assigned to ALT + TAB.
- 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:
- Shortcut GTA V, GTA V joystick on the computer
- How to use IFTTT with Raspberry Pi
- What is a shortcut? How to create a Shortcut on Windows
- 12 shortcuts help the PC run faster
- 10 great projects combining Raspberry Pi and Windows 10 IoT Core
- Tab shortcut keys in Chrome, Coc Coc, Edge, Firefox
- List of common Mac shortcuts
- Shortcuts to start Windows 10 in Hibernate mode or quickly turn off