Raspberry Pi – Matchbox Keyboard

Date:  Mar 9, 2019

I believed I blog this “Matchbox Keyboard” before.  But just to be sure, let’s write a blog entry on a year 2020 version.

When you have a small 3.5″ LCD monitor, and to make it portable, you will need a on-screen keyboard that you can toggle so to enter your commands.

Here are the steps you need to perform to make this keyboard appear in the top menubar.


Just to be sure, first updates the apps.

sudo apt update

sudo apt upgrade

After that, you can then install the Matchbox-Keyboard.

sudo apt install matchbox-keyboard

Once it is installed, you can launch it via the top menubar.

i.e. Menu -> Accessories -> Keyboard

Just in case you need to launch it on the Terminal, run the command


Now, we need to add the on-screen keyboard toggle to the taskbar

sudo nano /usr/bin/toggle-keyboard.sh

Write the following scripts into the file, i.e. toggle-keyboard.sh.  This script should be easy to understand.  If the keyboard exist (already running), kill it.  If the keyboard is not there, run the keyboard program.


PID=`p​idof matchbox-keyboard`

if [ ! -e $PID ]; then

kill $PID


matchbox-keyboard &


Remember to make it executable.

sudo chmod +x /usr/bin/toggle-keyboard.sh

Next, you will need to add this into the desktop menu bar

sudo nano /usr/share/raspi-ui-overrides/applications/toggle-keyboard.desktop

Write the following into this toggle-keyboard.desktop file.  Basically, this will instruct the Rasbian desktop to put an keyboard icon at the top menu bar there.  And once press, it will execute the toggle-keyboard.sh script.

[Desktop Entry]

Name=Toggle Virtual Keyboard

Comment=Toggle Virtual Keyboard






In order to make this keyboard icon clicable.  There is another file needed to be created.

nano /home/pi/.config/lxpanel/LXDE-pi/panels/panel

And palce these lines at the last of the file.

Plugin {


Config {

Button {





Once all these are done, simply reboot.

sudo reboot

Hereare the keyboard in action.

This is how you can add the applications onto the menu bar.  You can add other things in a similar manner too.


One comment

  1. Thanks for your helpful article! I ran into a little issue trying to run your script and, after some fiddling and online searches, came up with the following:


    if ! pgrep matchbox-keybo > /dev/null; then



    kill $( pgrep matchbox-keybo )


Leave a Reply