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
2. Install and compile matchbox-keyboard
pi@raspberrypi ~ $ cd matchbox-keyboard
pi@raspberrypi ~/matchbox-keyboard $ ./autogen.sh
pi@raspberrypi ~/matchbox-keyboard $ make
pi@raspberrypi ~/matchbox-keyboard $ sudo make install
Installation of the shared matchbox libraries needs to be done after the installation of matchbox-keyboard.
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;
And copy in the text below;
#!/bin/bash #This script toggle the virtual keyboard PID=`pidof matchbox-keyboard` if [ ! -e $PID ]; then killall matchbox-keyboard else matchbox-keyboard& fi
Now make it executable;
We will now add an item to the start menu;
For older images;
For newer images, including Jessie
Copy in this text;
[Desktop Entry] Name=Toggle Matchbox Keyboard Comment=Toggle Matchbox Keyboard Exec=toggle-matchbox-keyboard.sh Type=Application Icon=matchbox-keyboard.png Categories=Panel;Utility;MB X-MB-INPUT-MECHANSIM=True
To create an icon on the task bar, open up the LXDE panel config;
If the above file is empty, then it is most likely that you have a newer version of Raspbian, especially if you are using a Pi 2. You then would need to edit the panel config at this location;
If using RASPBIAN WHEEZY:
If using RASPBIAN JESSIE:
Find this section of config (it is near the bottom);
Plugin { type = launchbar Config { Button { id=lxde-screenlock.desktop } Button { id=lxde-logout.desktop } }
and change it to;
Plugin { type = launchbar Config { Button { id=toggle-matchbox-keyboard.desktop } Button { id=lxde-screenlock.desktop } Button { id=lxde-logout.desktop } }
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;
Alternately, if you have SSH’d in from another PC, use;
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;
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.
[wp_ad_camp_3]
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.
rgds,
-ds-
Thanks… I have added libxft-dev to the instructions.
./autogen.sh this doesn’t work
./autogen.sh: 2: ./autogen.sh: autoreconf: not found
you need to install autoconf and libtool
sudo apt-get install autoconf libtool
DISPLAY=:0.0 matchbox-keyboard
matchbox-keyboard: error while loading shared libraries: libmatchbox-keyboard.so.0: cannot open shared object file: No such file or directory
i see nothing
Did you install the Matchbox libraries?
sudo apt-get install libmatchbox1 -y
libmatchbox1 is already the newest version.
Got a similar problem with frans and solved it forcing an reinstall
apt-get –reinstall install libmatchbox1 -y
I’m using Rasbian Jessie with Kernel 3.12.26 and I can’t install matchbox-keyboard. I used the following commands:
git clone https://github.com/mwilliams03/matchbox-keyboard.git
cd matchbox-keyboard
./autogen.sh
make
the results:
base-fragment-et_EE.xml.in > base-fragment-et_EE.xml.tmp
cp base-fragment-et_EE.xml.tmp base-fragment-et_EE.xml
make[2]: *** No rule to make target ‘keyboard-extended.xml.in’, needed by ‘keyboard-extended.xml.tmp’. Schluss.
rm base-fragment-da_DK.xml.tmp base-fragment-et_EE.xml.tmp
make[2]: Leaving directory ‘/home/pi/matchbox-keyboard/layouts’
Makefile:486: recipe for target ‘all-recursive’ failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory ‘/home/pi/matchbox-keyboard’
Makefile:375: recipe for target ‘all’ failed
make: *** [all] Error 2
in ~/matchbox-keyboard/layouts/, “keyboard-extended.xml.in” file is missing.
cd ~/matchbox-keyboard/layouts/
cp keyboard-extended.xml keyboard-extended.xml.in
then retry.
Thank you for your tip!
Hello, I got the same problem. Unfortunately, everyone seemed to ignore this. Is there a solution?
Thanks.
First of all thanks for the awesome PiScreen. I am a beginner with Raspberry Pi. I was wondering if it is possible to support multiple PiScreens simultaneously with a single Raspberry Pi or Banana Pi or any of its high-end variants? Can I connect PiScreen using USB port and what can I do to achieve this?
I shall be grateful for the response and any helpful details/insights into this.
Thanks
S
hello it is a good post, but now i need install extended, can you tell made a tutorial how to make it??
sudo nano /usr/bin/toggle-matchbox-keyboard.sh
change
matchbox-keyboard&
to
matchbox-keyboard -s 75 extended&
Is it possible to add the following characters on the keyboard {, }, &, and | and numbers? If so, how?
first try loading the extended keyboard and see if that gives you what you want
matchbox-keyboard extended
Otherwise, read the README in the source directory. It has a section titled “Making your own keyboard layouts”
How do you set the language xml file you wish to use? And how can languages be switched during use?
matchbox-keyboard –lang extended
matchbox-keyboard –lang sv_SE
I could not get the toggle script to work properly until I changed the line:
PID=’pidof matchbox-keyboard’
To this:
PID=$(pidof matchbox-keyboard)
It would only keep launching additional keyboards before making this change.
I can’t tell you exactly why… I just kept looking at examples of scripts and looking for other ways to write it until I got it to work.
I know this is a long time after, but for posterity sake… If someone is trying to copy and paste, it is possible that instead of a backtick, you copied or typed a single quote. The two are totally different in the scope of shell scripting.
Hello,
I have change
matchbox-keyboard -s 75 extended&
In:
sudo nano /usr/bin/toggle-matchbox-keyboard.sh
But, when i launch the matchbox on the menu, it alway launch the “Standart” non extended keyboard. what’s wrong?
Alors after changer text in ~/.config/lxpanel/LXDE/panels/panel and rebboted the device, the line i have editer have diseapear, now , POWER and LOCK icon has diseaper from the taskbar, i dont know why
Hello,
It’s now working, i have erase all space or “tab” space and now it’s working (on your example, have space and Tab and i have delete it and woking great now)
I have just a question, it is possible to have a “more extended” keyboard (like with Up,Down,Right,Left, inser, home, delete, etc… Key)?
Best regards.
Etienne
Some instructions to create your own layouts here;
https://github.com/xlab/matchbox-keyboard
http://wiki.openmoko.org/wiki/Change_matchbox_keyboard_layout
You can also find some examples here;
/usr/local/share/matchbox-keyboard/
I have followed the installation instructions and the standard matchbox keyboard works fine. When I try to get the extended version to work:
matchbox-keyboard extended
I get “Segmentation fault”. Can you help me troubleshoot this?
got the same. did you solve it?
I also get a segfault with any keyboard except the default. Help.
Default and extended work for me, but any of the others gives me a segfault. I can only assume that the older layouts are duffed. I’m running on Raspberry Pi 3 and a 7″ touchscreen wit Jessie
This edit location has changed for the Pi2
pi@raspberrypi ~ $ nano ~/.config/lxpanel/LXDE/panels/panel
it is now
pi@raspberrypi ~ $ nano ~/.config/lxpanel/LXDE-pi/panels/panel
Will this affect any of the coding?
It seems to work.
I cant make the toggle work, could you help me to install the last version (https://github.com/xlab/matchbox-keyboard). What i really want is to make the virtual keyboard runs on startup. Please some help, Im newbie
how can I put it always on top?
I executed all steps in the tuturial, but same as frans (AUGUST 29, 2014 AT 1:20 AM) I get the following error message:
matchbox-keyboard: error while loading shared libraries: libmatchbox-keyboard.so.0: cannot open shared object file: No such file or directory
uname -a
Linux raspberrypi 3.18.9-v7+ #767 SMP PREEMPT Sat Mar 7 21:52:35 GMT 2015 armv7l GNU/Linux
Can you please advise? Thanks
Do you install libmatchbox libraries? (sudo apt-get install libmatchbox1 -y )
Hi Fernando, I appreciate your reply. However:
“libmatchbox1 is already the newest version.”
Any other advise?
Thanks,
Guus
Hi all, first of all Mark I appreciate all the work that has gone in to this. Very useful tool for the pi with the small touchscreen. First of all the tutorial is well written and concise which I appreciate. In the line “X-MB-INPUT-MECHANSIM=True” is it supposed to be MECHANISM or how its typed? I also have run through this two times. The first time I felt that I had missed installing libmatchbox1 in the appropriate sequence so I reimaged and tried the script again installing libmatchbox at an earlier time. I still receive the
matchbox-keyboard: error while loading shared libraries: libmatchbox-keyboard.so.0: cannot open shared object file: No such file or directory
I am using the raspian pitft image PiTFT28R_raspbian140620_2014_08_25. I’ve checked the error logs and no error seems to be logged.
Any and all advice is appreciated this tool would cure a number of remote uses I have in mind for this unit. thanks Jim
I am getting this error
configure: error: *** You need to install libfakekey from MB SVN ***
I got the same error. Time to start googling…
Turns out there’s a much easier process now. (Though it didn’t show up in the Menu for me, but works properly.)
http://www.modmypi.com/blog/matchbox-keyboard-raspberry-pi-touchscreen-keyboard
Getting Directory ( ~/.config/lxpanel-pi/LXDE/panels/panel) not found when trying to write the code to the file.
hi Jim
i also got this error.
did u solve it
Hi.
I’ve installed the keyboard as per instructions but after running it I can’t open File Manager without a reboot and then if I run matchbox-keyboard File Manager will not open.
Anyone else having this problem? How can I fix it?
Thanks
Hi,
I also got the same problem as Matthew Grant, I just installed the virtual keyboard and cannot access the file manager.
Has anybody found the fix for this?
thanks
I had the same pb.
I have change the toggle script to load the extended keyboard with 50 % size
I have also set the keyboard to be always on top. (top left corner menu)
And now it is ok.
It is strange but I suspect something with the default full size !
I have this pb too !
Should the keybord disappear when I touch the launchbar’s icon? Because I get a second keyboard…
Any suggestions?
Hello!
I already installed matchbox-keyboard with described steps and everything works fine. But this is quite old version, and I need options to control position and size of keyboard.
I found new version and I had try to build matchbox-keyboard 1.5 from site: https://github.com/xlab/matchbox-keyboard
I had git cloned project and run following commands:
git clone https://github.com/xlab/matchbox-keyboard.git
cd machbox-keyboard
./autogen.sh
and when run make, I got following errors:
make all-recursive
make[1]: Entering directory ‘/home/pi/matchbox-keyboard_/matchbox-keyboard’
Making all in src
make[2]: Entering directory ‘/home/pi/matchbox-keyboard_/matchbox-keyboard/src’
/bin/bash ../libtool –tag=CC –mode=link gcc -g -O2 -o matchbox-keyboard matchbox-keyboard.o matchbox-keyboard-image.o matchbox-keyboard-layout.o matchbox-keyboard-row.o matchbox-keyboard-key.o matchbox-keyboard-ui.o matchbox-keyboard-xembed.o matchbox-keyboard-remote.o config-parser.o util-list.o util.o matchbox-keyboard-ui-xft-backend.o -lX11 -lXtst -lfakekey -lXft -lexpat -lpng12
libtool: link: gcc -g -O2 -o matchbox-keyboard matchbox-keyboard.o matchbox-keyboard-image.o matchbox-keyboard-layout.o matchbox-keyboard-row.o matchbox-keyboard-key.o matchbox-keyboard-ui.o matchbox-keyboard-xembed.o matchbox-keyboard-remote.o config-parser.o util-list.o util.o matchbox-keyboard-ui-xft-backend.o -lX11 -lXtst -lfakekey -lXft /usr/lib/arm-linux-gnueabihf/libexpat.so -lpng12
/usr/bin/ld: matchbox-keyboard-ui-xft-backend.o: undefined reference to symbol ‘XRenderComposite’
//usr/lib/arm-linux-gnueabihf/libXrender.so.1: error adding symbols: DSO missing from command line
collect2: ld returned 1 exit status
Makefile:361: recipe for target ‘matchbox-keyboard’ failed
make[2]: *** [matchbox-keyboard] Error 1
make[2]: Leaving directory ‘/home/pi/matchbox-keyboard_/matchbox-keyboard/src’
Makefile:416: recipe for target ‘all-recursive’ failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory ‘/home/pi/matchbox-keyboard_/matchbox-keyboard’
Makefile:305: recipe for target ‘all’ failed
make: *** [all] Error 2
Since I’m new in RPI and linux, can anyone help to resolve this issue and install this version ?
Thank you !
Hi.
when I run this keyboard program any files or folders on my desktop disappear and cannot be seen until a restart, has anyone else had this issue? anyone know a fix?
As a workaround to fix this issue, I’ve edited my /usr/bin/toggle-matchbox-keyboard.sh to show extended layout at 75% width as follows (note the change in ‘else’ statement):
#!/bin/bash
#This script toggle the virtual keyboard
PID=`pidof matchbox-keyboard`
if [ ! -e $PID ]; then
killall matchbox-keyboard
else
matchbox-keyboard -s 75 extended &
fi
This is based on Joe’s observation that 75% screen with extended layout is working good.
Note: the command for configuring the taskbar on Raspbian Jesse (R-Pi 2) should be
“pi@raspberrypi ~ $ nano ~/.config/lxpanel/LXDE-pi/panels/panel”
not
“pi@raspberrypi ~ $ nano ~/.config/lxpanel-pi/LXDE/panels/panel”
Thanks for the heads up, i have updated the page.
+Mark Williams: I am a total newbie to linux. On Step3 I pasted the code Create a new file and a terminal window pops up. Then I copied the next code window and pasted it into the termina window. THEN WHAT do I press to continue … before [in a new terminal window, I assume] We will now add an item to the start menu. Please add newbie baby-steps to your instructions – THANKS.
Exit ‘nano’ and select yes to save the file.
Ctrl-X to exit nano
+Mark Williams: ok that worked and so did “make it executable”
Had an error on add item to start menu: it asks File Name to Write:$top
I pressed <- return and got
[Error writing /usr/local/share/applications/toggle-matchbox-keyboard.desktop]
… thanks for the handholding
Mark –
I can confirm “toggle martchbox keyboard” is NOT in the start menu.
And i botched-up something and the Menu>Applications>Keyboard does not work any more.
Also yes to SUDO as I cut/pasted exactly per your instructions.
QUESTION: is there any Pi equivalent to TeamViewer so your could “see” what I’m seeing on my 7: Pi display and with SSH correct the code?
FYI – George Fetters [met him at the MeetUp this Saturday in St. Charles] will be here tomorrow night so hopefully he can resolve several matters. I’ll also be at the Feb 20 meetup in St. Charles – hope you’ll be there too so we can meet.
Jim
Mark:
“toggle martchbox keyboard” is NOT in the start menu
I copied/ pasted each line from your post so YES on SUDO if it was in your post
George Fetters coming over here Thursday night – I’m sure he can help.
I’ll also be at the Feb 20 meetup in St. Charles – hope to see you there
Jim
“toggle martchbox keyboard” NOT in the start menu
if SUDO was in your instructions then I cut/pasted it in.
George Fetters will be at my house Thurs [tomorrow] – I’m sure he can help.
Jim
… however it DOES now appear in the Menu > Applications > Pop-Out list of choices – and works just fine. Still needing help with above error “adding item to start menu”. Thanks. Jim.
Just confirming, if you have “toggle martchbox keyboard” in the start menu and it turns on and off the keybaord, I think you can disregard the error message.
If it still isnt working, can you confirm you entered ‘sudo’ before nano
“toggle martchbox keyboard” NOT in the start menu
if SUDO was in your instructions then I cut/pasted it in.
George Fetters will be at my house Thurs [tomorrow] – I’m sure he can help.
Jim
Mark
I restarted from step 1.
In Step 2 you CD to matchbox-keyboard
pi@raspberrypi ~ $ git clone https://github.com/mwilliams03/matchbox-keyboard.git
pi@raspberrypi ~ $ cd matchbox-keyboard
pi@raspberrypi ~ $ ./autogen.sh
pi@raspberrypi ~ $ make
pi@raspberrypi ~ $ sudo make install
but you never CD back to root ? So I ended up running the last 3 commands as
~/matchbox-keyboard $ ./autogen.sh
~/matchbox-keyboard $ make
~/matchbox-keyboard $ sudo make install
~/matchbox-keyboard $ sudo apt-get install libmatchbox1 -y
and so forth until I realized my error and CD back to root
then
pi@nutonePi ~/matchbox-keyboard $ cd
pi@nutonePi ~ $ sudo nano /usr/bin/toggle-matchbox-keyboard.sh
pi@nutonePi ~ $ sudo nano /usr/local/share/applications/toggle-matchbox-keyboard.desktop
pi@nutonePi ~ $ nano ~/.config/lxpanel/LXDE/panels/panel
I am using RASPBIAN JESSIE so I ran:
pi@nutonePi ~ $ nano ~/.config/lxpanel/LXDE-pi/panels/panel
And could NOT find and replace this section of code
Plugin {
type = launchbar
Config {
Button {
id=lxde-screenlock.desktop
}
Button {
id=lxde-logout.desktop
}
}
NOW what should i do?
i need to reflash the 8gb chip and start over.
In trying to get the keyboard to work I’ve messed up so much I just need to start over and WAIT for some experienced people to help me.
My big question for you, Mark, is in your step 2 instruction set:
You show:
pi@raspberrypi ~ $ git clone https://github.com/mwilliams03/matchbox-keyboard.git
pi@raspberrypi ~ $ cd matchbox-keyboard
pi@raspberrypi ~ $ ./autogen.sh
pi@raspberrypi ~ $ make
pi@raspberrypi ~ $ sudo make install
shouldn’t it show:
pi@raspberrypi ~ $ git clone https://github.com/mwilliams03/matchbox-keyboard.git
pi@raspberrypi ~ $ cd matchbox-keyboard
pi@raspberrypi ~ /matchbox-keyboard $ ./autogen.sh
pi@raspberrypi ~ /matchbox-keyboard $ make
pi@raspberrypi ~ /matchbox-keyboard $ sudo make install
then
pi@raspberrypi ~ /matchbox-keyboard $ cd
pi@raspberrypi ~ $
[now user is ready for step 3]
I’m a very ancient DOS user and expect the Linux command line to work the same way.
THAT is what has me greatly confused.
Blessings, Jim
you are correct. I will get the page updated.
Jim, i think I have found the problem. In step 3. when you need to create the .desktop file.. the location for Jessie is different. I will update the instructions above
/usr/share/applications/toggle-matchbox-keyboard.desktop
Mark, very good job. Like it very much.
The Install prerequisite development files line is not working for me but doing this in separate steps it works.
My problem is after reboot the cpu is 0% but after first use of the keyboard it stays at 25%
What is the pi doing here?
From that state doing a reboot the screen will get black with a blinking cursor top left.
And stays there like frozen.
After cutting the power reboot will take place.
Oh most important is that after first use of keyboard the file manager is no longer working.
That needs to be fixed.
OK. I admit. My Fault.
I should have read the comments more carefully.
My problems occur only on default compilation / installation.
After chosen another keyboard (the extended) in 75%
everything seems to be ok now.
CPU load is 0%
File manager is fully usable.
Reboot is as fast as before (immediate)
Sorry for confusion.
Last question:
Is there a repository one can load and download keyboards?
so nobody has to invent the same over and over again?
Regards Joe
I’m not able to execute “make” following message: make: *** No targets specified and no makefile found. Stop.”
What is my problem?
see point 2.
are you in the right directory ??
Hi, I have a problem i can’t install the Matchbox libraries
So I have icon of Toggle Matchbox Keyboard but I can’t open it
Anyone else having this problem? How can I solve it?
Thanks
You can now install by:
sudo apt-get install matchbox-keyboard
Helpful article, tested the keyboard. But: How can i remove the keyboard-install from the article?
Thanks!
Never mind:
Going to the right directory of the app and then: sudo make uninstall did the job. I guess?
Ok like that?
Kind regards,
You have a misspelling in the tutorial.
sudo nano /usr/share/applications/toggle-matchbox-keyboard.desktopp
should be
sudo nano /usr/share/applications/toggle-matchbox-keyboard.desktop
There is one p to much.
I still have the 25% CPU problem. I use “matchbox-keyboard -s 75 extended &” in the else statement (RPI 3 with Jessie and 7” Toch Display).
Thanks for the tutorial.
Hello there,
I am trying to use this matchbox-keyboard on a raspberry pi and haven’t been able to find a way to modify it to provide me with a large keyboard, the size of my screen (7″ in my case), just for the purpose of entering the numeric login pass-code for a program.
No matter what I tried, I couldn’t change the height of the buttons.
Is there anything that can be changed in the configuration such that I can specify this parameter?
Thank you in advance
Hi,
thank you for this. But each time I enable matchbox-keyboard, my desktop icons disappear! How can I avoid that?
Thanks
Hi
How can I add numbers to this keyboard?
Just installed the matchbox keyboard. I think the extended version should be the default but I am very pleased.
Your installation instructions were detailed, easy to follow and worked flawlessly.
I suggest changing the wording for changing the “panel” file to “add button as shown”. My file had different wording for the other buttons.
Great job. Thank you.
Larry