Creating Custom Raspberry Pi OS Keyboard Shortcuts

게시자

Raspberry Pi single-board computers have an excellent GUI called Raspberry Pi OS (formerly Raspbian). This makes getting started easy, but what if you want to launch an often-used program with a certain keyboard combination, rather than dragging your mouse to the corresponding icon? Or what if your keyboard is missing a certain button that you need, like “print screen?”

The good news is that assigning custom Raspberry Pi keyboard shortcuts is definitely possible, though you’ll need to do a bit of text file editing. Open up your terminal by clicking the appropriate icon in Raspberry Pi OS, or better yet with Ctrl-Alt-t, to get started on your custom input journey.

The example below shows one custom input example. How it works is discussed further in the sections below:

RP Keyboard Shortcuts Image 2

    <!-- Custom Keyboard Shortcuts -->

    <keybind key="A-p">

      <action name="Execute">

        <command>scrot</command>

      </action>

    </keybind>

    <keybind key="C-A-c">

      <action name="Execute">

        <command>chromium-browser</command>

      </action>

    </keybind>

Advanced Settings: XML Modification

In the terminal, enter sudo nano /etc/xdg/openbox/lxde-pi-rc.xml. Scroll down to the line that says <keyboard>, or you can search for it by pressing Ctrl-w. On a new line following the </chainQuitKey> tag, enter the comment <!-- Custom Keyboard Shortcuts --> (or similar) to let you keep track of your new modifications.

Before actually making any modifications, scroll down through the lines following, noting the shortcut format. Breaking things down, the <keybind key="XXYY"> tag triggers a comand. The <action name="AABB"> tag then specifies what kind of action will be taken. Here we'll be using Execute as the action, in order to launch a program. Finally, the <Command> tag specifies that actual command to be executed.

Custom Keybind for Raspberry Pi

For the keybind key= tag, the format is "key1-key2-key3..." in whatever combination you desire. Note that the number of keys can be more or fewer than the three shown there, depending on your needs. Special keys have their own terminology, including:

  • A for Alt,
  • C for Ctrl,
  • S for shift
  • W for the "Windows" key

 

So Alt-p would be A-p, or if you want to use Ctrl as well, you'd add C-A-p here.

Command

RP Keyboard Shortcuts Image 3

The "%U" or other similar text following the main command can often be omitted.

Once triggered, the command line executes whatever comes after. If you need an alternate to printscreen, you'd type in scrot between the tags—the same command that you'd use to launch the printscreen program from the terminal. Other commands can be found by right-clicking on a taskbar icon, selecting properties, then the Desktop Entry tab. To launch VLC media player, for instance, you'd enter the line: <command>/usr/bin/vlc</command>, with the launch command between the opening and closing tags.

Exit and save, then reboot to activate your custom keyboard shortcuts.

Pi Keyboard Shortcut Application

It’s possible that you may never need to use a custom shortcut command, as the Raspberry Pi Operating System has several built-in, and you’ll often be using the terminal anyway. I got started down this road when working on the Raspberry Pi/Analog Discovery 2 oscilloscope. My Bluetooth keyboard didn’t have an actual print screen button, and I needed a way to get screenshots for the documentation found here. At the time, I just plugged in another keyboard, but this is a rather inelegant solution.

Whether you’re missing an important (to you) key or need to run a certain program in a flash, having the ability to make custom Raspberry Pi OS shortcuts is a great option to have at your disposal.

최신 뉴스

Sorry, your filter selection returned no results.

개인정보 보호정책이 업데이트되었습니다. 잠시 시간을 내어 변경사항을 검토하시기 바랍니다. 동의를 클릭하면 Arrow Electronics 개인정보 보호정책 및 이용 조건에 동의하는 것입니다.

당사의 웹사이트에서는 사용자의 경험 향상과 사이트 개선을 위해 사용자의 기기에 쿠키를 저장합니다. 당사에서 사용하는 쿠키 및 쿠키 비활성화 방법에 대해 자세히 알아보십시오. 쿠키와 추적 기술은 마케팅 목적으로 사용될 수 있습니다. '동의'를 클릭하면 기기에 쿠키를 배치하고 추적 기술을 사용하는 데 동의하는 것입니다. 쿠키 및 추적 기술을 해제하는 방법에 대한 자세한 내용과 지침을 알아보려면 아래의 '자세히 알아보기'를 클릭하십시오. 쿠키 및 추적 기술 수락은 사용자의 자발적 선택이지만, 웹사이트가 제대로 작동하지 않을 수 있으며 사용자와 관련이 적은 광고가 표시될 수 있습니다. Arrow는 사용자의 개인정보를 존중합니다. 여기에서 당사의 개인정보 보호정책을 읽을 수 있습니다.