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
+ C
to 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
+ T
from 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
+ W
to 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
+ F4
as 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 comment5. 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
+ a
and A-F2 will be ALT
+ F2
. Special keys such as CTRL
and ALT
have 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 keyboard
at 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 CTRL
+ ALT
+ Enter
will 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".
The chromium-browser command launches ChromiumYou 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
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:
- 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:
http://openbox.org/wiki/Help:Actions
You should read it
- What is a shortcut? How to create a Shortcut on Windows
- Learn about custom variables in Google Analytics
- How to create custom directives in Vue
- How to create a printer shortcut on Windows 10
- How to create custom functions in Google Sheets
- How to create a new user in Raspberry Pi OS
- How to create custom grid systems in Photoshop
- The shortcut virus removal has never been this simple
- How to Set a Keyboard Shortcut to Open Spotlight
- 4 common problems when installing custom ROMs on Android
- How to create a shortcut to clean the Recycle Bin on Windows 10/11
- How to create custom gradients using Photoshop CC
Maybe you are interested
How to manage date and time in React using Moment.js 10 free Email programs for Windows 2018 How to delete, replace or edit links in PDF documents with PDF Link Editor How to recruit, find jobs quickly on Facebook How to add trusted friends to Facebook on iPhone, Android The 66-year-old Buddha taught meditation to make life more peaceful and fun