raspberry pi os with matchbox virtual keyboard on screen

How to Install On-Screen / Virtual Keyboard in Raspberry Pi

One of the greatest things about the Raspberry Pi is how small a computer it is. But if you want to keep it compact by using a touch screen, or if your Pi doesn’t have a keyboard, how can you type? In this situation, an on-screen or virtual keyboard can be very useful.

On Raspberry Pi OS, a package named “matchbox” is available in the default repository and can be installed to enable a virtual keyboard on your screen. After the installation, the keyboard is available under “Accessories” in the main menu.

It’s particularly convenient for touchscreens, like the RasPad 3 I tested in this article. It’s like an iPad with a Raspberry Pi inside. In this article, I will show you how to install the virtual keyboard, including how to use it and a few extra tips.

If you need help getting started on Raspberry Pi, I have an entire course to guide you through your first steps. I’ll help you use the perfect hardware, plug everything in and install your first system. You’ll also do your first projects with me, just to make sure you are ready for the next level. Get all the information on this page if you are interested.

Want the best experience? Become a premium member for ad-free browsing, access exclusive content, and ask questions in our private forums. Your membership helps support the site!

Updating Raspberry Pi OS

In this step, you’ll want to make sure you have a graphical desktop environment.

Install Raspberry Pi OS

Obviously, the first step is to install an operating system on your Raspberry Pi. If you need some help installing Raspberry Pi OS, you can read my detailed tutorial here. The Desktop version is required to install the virtual screen on it.

But, if you don’t have a keyboard at home, you might get stuck during the configuration. How do you configure the network or complete the welcome wizard without a keyboard?

That’s why this tutorial for a headless installation on Raspberry Pi Zero will probably help.

You’ll learn how to configure the network and enable SSH from your computer, so you don’t need a keyboard. I often use this method when I create a new SD card, even if I have a good wireless keyboard. This saves time on each installation.

Update the System

Once your operating system is installed, there’s one more step step. As I mentioned, the package is available in the default Raspberry Pi OS repository. So, it’s a good idea to start by updating your system.

Here are the commands to update all packages from a terminal:
sudo apt update
sudo apt upgrade
sudo reboot

Download the Pi Glossary!
If you are lost in all these new words and abbreviations, request my free Raspberry Pi glossary here (PDF format)!
Download now

You can also do this in the “Add/Remove Software” tool if you prefer:
Go to the main menu > Preferences > Add/Remove Software.
Then click on Options > Check for Updates and upgrade everything.

raspberry pi os menu open showing update

Are you a bit lost in the Linux command line? Check this article first for the most important commands to remember and a free downloadable cheat sheet so you can have the commands at your fingertips.

Enable SSH (Optional)

If you use a touch screen or don’t have a keyboard, it’s probably a good idea to enable SSH on your Raspberry Pi (if you didn’t already do it during the installation, as explained here). This way, you can install and configure new packages from your computer.

This step is optional, but here’s how to do it:

  • Open the main menu.
  • Go to Preferences > Raspberry Pi Configuration.
  • Then enable SSH in the Interfaces tab.
    raspberry pi configuration enabling ssh

You can now connect to your Raspberry Pi from your computer.
On Windows, you need a software like Putty.
On Linux, you can use a terminal with the command: ssh <username>@<ip>
You’ll find more details on SSH in this tutorial if needed.

Installing the Virtual Keyboard Package

Now that you have an updated desktop, we can finally install the virtual keyboard package. I will show you how to do this with two methods: directly on Raspberry Pi OS with Desktop or via SSH.

Installation on Raspberry Pi OS Desktop

If you have a keyboard for the installation, you can do this directly in the desktop interface:

  • Open the main menu.
  • Go to Preferences > Add/Remove Software.
  • In the search field, type “matchbox” and press Enter.
  • In the results, find the “on-screen keyboard” package.
    The package name is something like “matchbox-keyboard.”
    Check the corresponding box.
    add remove software on raspberry pi os 64-bit showing matchbox virtual keyboard package
  • Click on “Apply” to install it.
    The system will automatically install the package dependencies.

You can now exit this tool and go directly to the section on using the virtual keyboard.

Installation via SSH

If you don’t have a keyboard available, you can also install the package remotely from a different computer, if SSH is enabled:

That’s it! You can now switch back to the Raspberry Pi screen and read the next section.

Using the Virtual Keyboard

Now that you’ve installed the virtual keyboard, in this section, I’ll show you how to use it.

Warning: As of this writing, the virtual keyboard (matchbox-keyboard) does not work properly on Raspberry Pi OS (Bookworm), unless you use the fix below.

The issue is compatibility with the new Linux display server, Wayland. I’m sure they’ll sort things out in time, but until then, switch your Pi to the traditional X11 display server to fix it:

  • Enter this command into a terminal:
    sudo raspi-config
  • Go to Advanced Options -> Wayland
    switching from wayland to  x display server inside raspi-config
  • Choose X11. Hit Ok.
  • Go down and hit Finish. When asked to reboot, hit Yes.

Open the Keyboard

Once installed, the keyboard is available in the main menu.
Go to main menu -> Accessories and click “Keyboard.”
The virtual keyboard will now show up on your screen.

raspberry pi os with matchbox virtual keyboard on screen

If it’s too small, drag the corners like any program to increase its size. Or, right-click on the program in the taskbar, and click “Maximize”:

Download the Pi Glossary!
If you are lost in all these new words and abbreviations, request my free Raspberry Pi glossary here (PDF format)!
Download now
matchbox-keyboard showing context menu option to maximize

From there, the usage is intuitive (it’s really similar to a smartphone keyboard). You can also move the keyboard where you want (if you prefer it at the bottom for example).

Create a Shortcut

If you plan to use the virtual keyboard all the time, launching it from the main menu is not the most practical. Instead, you can create a shortcut in the top bar:

  • Right-click on an icon from the top bar (Terminal for example).
  • Click on “Application Launch Bar Settings”:
  • A window like this shows up:
  • Find the keyboard application on the right and click on “Add” to add it on the left.
  • Close the window.
  • The icon is now available on the top bar:

Autostart With Raspberry Pi OS

What if you want the virtual keyboard to be available on startup? I already have a post on how to autostart programs on boot. But unfortunately, none of those methods work well in this case.

If you add the “matchbox-keyboard” command to the autostart file, the keyboard will open at a minimal size, which is not very useful. So, I created a script with a wait time while the Desktop is loading.

There’s probably a more elegant way to do this, but here’s a method that worked for me:

  • From your computer, connect to the Raspberry Pi via SSH.
  • Create a new script in /usr/local/bin (or anywhere else):
    sudo nano /usr/local/bin/keyboard.sh
  • Paste the following lines:
    #!/bin/bash
    sleep 5
    /usr/bin/matchbox-keyboard
  • Save & exit (CTRL+O, CTRL+X).
  • Make the script executable:
    sudo chmod +x /usr/local/bin/keyboard.sh
  • Edit the following file:
    sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
  • Add this line at the end:
    @/usr/local/bin/keyboard.sh
  • Save & exit

After a reboot, everything is good; the keyboard shows up in full size automatically.

Download Your Essential Linux Commands Guide!
It's a free PDF guide containing every Raspberry Pi Linux command you should know!
Download now

Video Tutorial

If you want to follow along as I enable the virtual keyboard on my Raspberry Pi, you can watch this video on my YouTube channel where I do exactly that:

Download Your Essential Linux Commands Guide!
It's a free PDF guide containing every Raspberry Pi Linux command you should know!
Download now

🛠 This tutorial doesn't work anymore? Report the issue here, so that I can update it!

If you are looking for exclusive tutorials, I post a new course each month, available for premium members only. Join the community to get access to all of them right now!

Conclusion

That’s it! You now know how to install an on-screen keyboard on your Raspberry Pi.
In general, I prefer using a wireless keyboard (as explained here), but this solution may help if you have no other choice.

Obviously, you can also use a remote access tool like Anydesk to control your Pi from your computer, or any other remote desktop solutions (I list my favorites one here).

I hope this post was useful for you. Ultimately, it’s probably better to get a keyboard for your Raspberry Pi if you start being serious with it. I tested many of them over the years, and you can find my current recommendations here.

There is no one size fits all for this, the best keyboard for you depends on your needs and how you use your Raspberry Pi, it’s not necessarily the same as mine. Click on the previous link to know which one you should use.

Whenever you’re ready, here are other ways I can help you:

The RaspberryTips Community: If you want to hang out with me and other Raspberry Pi fans, you can join the community. I share exclusive tutorials and behind-the-scenes content there. Premium members can also visit the website without ads.

Master your Raspberry Pi in 30 days: If you are looking for the best tips to become an expert on Raspberry Pi, this book is for you. Learn useful Linux skills and practice multiple projects with step-by-step guides.

The Raspberry Pi Bootcamp: Understand everything about the Raspberry Pi, stop searching for help all the time, and finally enjoy completing your projects.

Master Python on Raspberry Pi: Create, understand, and improve any Python script for your Raspberry Pi. Learn the essentials step-by-step without losing time understanding useless concepts.

You can also find all my recommendations for tools and hardware on this page.

How would you rate this article?

Click on a star to rate it!

Average rating / 5. Vote count:

No votes so far! Be the first to rate this post.

As you found this post useful...

Spread the word!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Similar Posts

3 Comments

  1. There is one big challenge: what if you only have a mouse and a screen? No ssh, no vnc… Start the add/remove programs and find the matchbox on screen keyboard. But wait… the search option does not work without a keyboard… where to find the matchbox installation file… in which category? You can find it in the System catagory, alphabetic under the M…
    Click apply and enter your password. Probably the default “raspberry”. But wait… you need a keyboard to enter the password… I am lost!
    No you are not: Open the texteditor from the Accessories startmenu. Now find the word “raspberry” (if that is your password) in any of the descriptionfiles from the add/remove program, and copy it. If you have another password, then find the right letters or numbers and copy them to the texteditor in the correct order. When ready, click apply in the add/remove software program and paste your password. After the install you have your virtual keyboard!

    1. Hi Tom,

      Ah ah, thanks for your message, it may help other people

      If you are in this case, the other idea is to do everything from your computer via SSH
      I have a tutorial for the beginning: https://raspberrytips.com/pi-zero-setup-without-keyboard/
      Then you can use apt to install the package and find a way to create a shortcut, following tom recommendation or other

  2. My keyboard has only upper and lowercase alphabetic characters, no numbers or punctuation – not a lot of use like that!

Comments are closed.