Matchbox Keyboard Raspberry Pi

Virtual Keyboard for the Raspberry Pi

Matchbox-keyboard is an on screen ‘virtual’ or ‘software’ keyboard which works well for small touchscreen TFTs connected to a Raspberry Pi.

Matchbox-keyboard also uses XML files to specify the layout of the keys, which makes it highly customizable.

The touchscreen used in the above video is a PiScreen.

1. Install prerequisite development files

pi@raspberrypi ~ $ sudo apt-get install libfakekey-dev libpng-dev libxft-dev autoconf libtool -y

2. Install and compile matchbox-keyboard

pi@raspberrypi ~ $ git clone
pi@raspberrypi ~ $ cd matchbox-keyboard
pi@raspberrypi ~ $ ./
pi@raspberrypi ~ $ make
pi@raspberrypi ~ $ sudo make install

Installation of the shared matchbox libraries needs to be done after the installation of matchbox-keyboard.

pi@raspberrypi ~ $ sudo apt-get install libmatchbox1 -y

3. Create toggle script to start or stop matchbox-keyboard
We will now create a script to toggle the keyboard on and off. And then add a menu item to access the script as well as add an icon to the task bar for easy access.


Create a new file;

pi@raspberrypi ~ $ sudo nano /usr/bin/

And copy in the text below;

#This script toggle the virtual keyboard
PID=`pidof matchbox-keyboard`
if [ ! -e $PID ]; then
killall matchbox-keyboard

Now make it executable;

pi@raspberrypi ~ $ sudo chmod +x /usr/bin/

We will now add an item to the start menu.

pi@raspberrypi ~ $ sudo nano /usr/local/share/applications/toggle-matchbox-keyboard.desktop

Copy in this text;

[Desktop Entry]
Name=Toggle Matchbox Keyboard
Comment=Toggle Matchbox Keyboard

To create an icon on the task bar, open up the LXDE panel config;

pi@raspberrypi ~ $ nano ~/.config/lxpanel/LXDE/panels/panel

Find this section of config (it is near the bottom);

Plugin {
type = launchbar
Config {
Button {
Button {

and change it to;

Plugin {
type = launchbar
Config {
Button {
Button {
Button {

More Information

Matchbox-keyboard can be started from the command line with the below statement. This needs to be run from a command prompt within X which is running on the touch screen;

pi@raspberrypi ~ $ matchbox-keyboard

Alternately, if you have SSH’d in from another PC, use;

pi@raspberrypi ~ $ DISPLAY=:0.0 matchbox-keyboard

This will load the default keyboard layout, seen here;

Matchbox-keyboard can also resize the window with the -s integer argument. Integer is a value between 30%-100% of the screen width.
Here is the defualt keyboard layout loaded at 50% of screen width;

pi@raspberrypi ~ $ matchbox-keyboard -s 50


Matchbox-keyboard also supports custom keyboards, and there are a few loaded with the install into /usr/local/share/matchbox-keyboard/. It is very easy to build your own.

pi@raspberrypi ~ $ matchbox-keyboard -s 50 extended


14 thoughts on “Virtual Keyboard for the Raspberry Pi”

  1. Pingback: <CONTENT /> v.6
  2. Remember to install libxft-dev if not done befor (sudo apt-get -y install libxft-dev).
    Otherwise the error:
    configure: error: *** Required Xft Library not found ***
    will occur.

      1. DISPLAY=:0.0 matchbox-keyboard
        matchbox-keyboard: error while loading shared libraries: cannot open shared object file: No such file or directory

        i see nothing

Leave a Reply