Add an On-Screen Keyboard to your Raspberry Pi (2024)

This guide will show you how to set up an on-screen keyboard for your Raspberry Pi.

Add an On-Screen Keyboard to your Raspberry Pi (1)

An on-screen keyboard can be incredibly useful for your Raspberry Pi in a variety of different cases.

For example, if you are using your Raspberry Pi with a touchscreen display, using an on-screen keyboard is one of the best ways of adding keyboard input.

Additionally, if you are running a Pi that does not have a keyboard connected and only a mouse, then using an on-screen keyboard will allow you to type still.

Installing an on-screen keyboard to your Raspberry Pi is a straightforward and quick task.

We will also be showing you how to add an icon to the taskbar to quickly toggle the virtual keyboard on and off.

Equipment List

Here is a list of the equipment we recommend for this guide on setting up an on-screen keyboard on your Raspberry Pi.

Recommended

  • Raspberry Pi
  • Micro SD Card
  • Power Supply
  • Ethernet Cable orWi-Fi
  • HDMI Cable
  • Monitor
  • USB Mouse or Touchscreen

Optional

  • Raspberry Pi Case
  • USB Keyboard

This guide was tested on a Raspberry Pi 4 running Raspbian Buster. This guide should work successfully on older versions of Raspbian as well.

Installing the On-Screen Keyboard Software to your Raspberry Pi

1. Before we can install the on-screen keyboard, we must first update our Raspberry Pi.

To upgrade the packages, we need to run the following two commands.

sudo apt updatesudo apt upgrade

Depending on how long it has been since you last updated, this process can take some time, so be patient.

2. Now that we have updated our Raspberry Pi, we can go ahead and install the software we want.

To install the virtual keyboard software, all we need to do is run the following command.

sudo apt install matchbox-keyboard

We chose to use the matchbox-keyboard package as its the most stable for the Raspberry Pi while also not chewing up to much of the Pi’s limited resources.

Opening the Virtual Keyboard on the Raspberry Pi

In this section, we will be showing you how to open the on-screen keyboard using both the terminal and the desktop menu.

Using the Desktop to Open the On-Screen Keyboard

1. Once you are on the desktop of your Raspberry Pi, click the icon in the top-left hand corner of the screen.

Add an On-Screen Keyboard to your Raspberry Pi (2)

This icon will bring up the start menu for the operating system.

2. Next, hover over “Accessories” (1.), this will bring up an additional menu

Within this new menu, clickKeyboard” (2.) to launch the software.

Add an On-Screen Keyboard to your Raspberry Pi (3)

3. The virtual keyboard should now be displayed on your Raspberry Pi’s desktop.

You can click/tap the letters to type into any textbox.

Add an On-Screen Keyboard to your Raspberry Pi (4)

Using the Terminal to Launch the Virtual Keyboard

If you can’t find the keyboard option within the start menu, you can also use the terminal to launch the software.

It is also possible to complete this section using SSH if you have no keyboard to connect to the Pi itself.

1. Start by opening up a terminal session on your Raspberry Pi whether that be over SSH or on the Pi itself.

2. Now within this terminal session, run one of the following commands.

The command you need to use differs if you are using SSH or running it directly on your Pi.

The reason for this is that we need to specify the display we want the virtual keyboard to display on when using SSH.

On the Raspberry Pi

matchbox-keyboard

Over SSH

DISPLAY=:0 matchbox-keyboard &

This command will load up the on-screen keyboard software on your Raspberry Pi.

Adding a Virtual Keyboard Toggle to the Taskbar

This section of the guide will show you how you can modify Raspbian so that you can add a keyboard toggle to your taskbar.

We will be making it so that when you click this button, it will automatically open and close the on-screen keyboard software.

1. We will start by creating the bash script that will toggle the matchbox software.

Begin writing this script in the “/usr/bin/” folder by running the following command.

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

2. Within this file, enter the following lines of code.

#!/bin/bashPID="$(pidof matchbox-keyboard)"if [ "$PID" != "" ]; then kill $PIDelse matchbox-keyboard &fi

This script is relatively straightforward. It first tries to grab the id of the virtual keyboard software and stores it in a bash variable called PID.

If it gets a process id, then the script will kill the currently running on-screen keyboard.

Otherwise, if there was no process id for the software, it will start it up by running the matchbox-keyboard command.

3. Once done, please save the file by pressing CTRL + X, then Y, followed by ENTER.

4. With our script created, we need to give everyone the execute privileges so that they can run it.

You can read more about permissions in linux with our file permissions in Linux guide.

To add the execute permission, run the following command.

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

If you would like to learn more about this command, check out our basics of chmod guide.

5. Next, we need to create the file which the taskbar will read to load our toggle button.

Begin creating this file by using the command below.

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

6. Within this file, enter the following lines.

[Desktop Entry]Name=Toggle Virtual KeyboardComment=Toggle Virtual KeyboardExec=/usr/bin/toggle-keyboard.shType=ApplicationIcon=matchbox-keyboard.pngCategories=Panel;Utility;MBX-MB-INPUT-MECHANISM=True

This text tells the operating system how it should display the entry, as well as telling it should execute the script we wrote when clicked.

7. Now, please save the file by pressing CTRL + X, then Y, followed by ENTER.

8. Next, we need to copy over the default configuration file over to our pi users config folder.

We will be modifying this file to add our on-screen keyboard button.

cp /etc/xdg/lxpanel/LXDE-pi/panels/panel /home/pi/.config/lxpanel/LXDE-pi/panels/panel

9. Finally, we need to modify the configuration for the pi user so that the icon is added to the taskbar.

Run the command below to begin modifying the panel configuration.

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

10. To the bottom of this file, add the following text.

Plugin { type=launchbar Config { Button { id=toggle-keyboard.desktop } }}

This bit of text creates an entry in the taskbar. It tells the taskbar to utilize the toggle-keyboard.desktop file we created earlier on in this section to display our toggle button.

11. Once added, please save the file by pressing CTRL + X, then Y, followed by ENTER.

12. To show our new button in the taskbar, we need to restart our Raspberry Pi by running the following command.

sudo reboot

13. When your Raspberry Pi finishes rebooting, you should now see the keyboard icon in the top right-hand corner of the screen.

By clicking this icon, you can toggle the on-screen keyboard on your Raspberry Pi on and off.

Add an On-Screen Keyboard to your Raspberry Pi (5)

Hopefully, at this stage, you have now successfully set up an on-screen keyboard on your Raspberry Pi.

If you have had any trouble with the virtual keyboard software, feel free to drop a comment below.

Recommended

JavaScript Bitwise Operators

How to use the date Command

How to Install Apache on macOS

Installing XBian to your Raspberry Pi

How to Install Node.js on Ubuntu

How to Install Pi-hole on Ubuntu

Add an On-Screen Keyboard to your Raspberry Pi (2024)

FAQs

Add an On-Screen Keyboard to your Raspberry Pi? ›

Go to Start , then select Settings > Ease of Access > Keyboard, and turn on the toggle under Use the On-Screen Keyboard. A keyboard that can be used to move around the screen and enter text will appear on the screen.

How do I add an On-Screen Keyboard? ›

Go to Start , then select Settings > Ease of Access > Keyboard, and turn on the toggle under Use the On-Screen Keyboard. A keyboard that can be used to move around the screen and enter text will appear on the screen.

How do I install Matchbox keyboard on Raspberry Pi? ›

Open a "Terminal" and type sudo apt install matchbox-keyboard . You will find it installed under "Accessories" with the name "Keyboard". In my opinion, florence is better and more intuitive, but it depends on the at-spi2-core package to work properly, or it will hang on first "keystroke".

How do I connect my keyboard to my Raspberry Pi? ›

So, connect your HDMI cable to your monitor and the Raspberry Pi Zero. Connect your USB hub to the Raspberry Pi Zero and connect your keyboard and mouse to the USB hub. Make sure that you connect all your devices before you power on the unit.

How do I add keyboard layout to Raspberry OS? ›

How to change the Keyboard Configuration on a Raspberry Pi
  1. On your Raspberry Pi, go to Preferences and select Mouse and Keyboard Settings. Choose Keyboard Layout.
  2. Select your keyboard layout then select OK.

What is the shortcut key for On-Screen Keyboard? ›

Open the Start Menu and go to All Programs, Accessories, Ease of Access, and select On-Screen Keyboard. Press Windows logo key + U, and then ALT+K.

Why won't my On-Screen Keyboard appear? ›

Select Start > Settings. In Settings, select Personalization > Taskbar. Turn the toggle on/off to enable/disable the on-screen keyboard. Click the keyboard icon on your taskbar to bring up the on-screen keyboard.

What keyboard works with Raspberry Pi? ›

Raspberry Pi Keyboards & Mice
  • (491 Reviews) Raspberry PiOfficial Raspberry Pi Keyboard & Mouse. ...
  • (105 Reviews) The Pi HutSuper Compact 2.4GHz Wireless Keyboard & Mouse. ...
  • (32 Reviews) ModMyPiCompact Keyboard Wired USB. ...
  • (15 Reviews) The Pi HutMini Bluetooth Keyboard – Black. ...
  • (16 Reviews) ...
  • (22 Reviews) ...
  • (1 Review) ...
  • (59 Reviews)

Do all keyboards work with Raspberry Pi? ›

If you can get any USB keyboard working with your other computer, then it should work with Raspberry Pi. Check your USB cable color coding. Green is usually D+.

What keyboard does Raspberry Pi use? ›

The official Raspberry Pi keyboard and hub is a standard 79-key (78-key US) keyboard that includes an additional three USB 2.0 type A ports to power other peripherals. The keyboard is available in different language/country options as detailed below.

Why is my keyboard not working with Raspberry Pi? ›

There are typically two reasons why a USB keyboard fails to operate correctly when connected to the Raspberry Pi: It's drawing too much power, or its internal chipset is conflicting with the USB circuitry on the Pi.

Can you use a Raspberry Pi without a keyboard? ›

If you want to set up a Raspberry Pi, but you don't have a separate keyboard or monitor with ports and cables that plug into the Pi, you'll want to perform what's called a “Headless Raspberry Pi” setup.

Can I use any mouse or keyboard on Raspberry Pi? ›

The UART interface is bidirectional. So, you can connect a keyboard and mouse to it. If the keyboard and mouse are USB compatible, you can connect them directly to the Raspberry Pi.

How do I add a keyboard to Linux? ›

If you want additional keyboard layouts, follow these steps:
  1. Open the Menu and click on System Settings:
  2. Click on Keyboards:
  3. Click on the Layouts tab and then on the plus sign in the lower left corner:
  4. Find and select the keyboard layout you want, and click Add:

How do I show my keyboard layout? ›

On a hardware keyboard, press and hold the Windows logo key , and then press the Spacebar to cycle through your input methods. If you have a touchscreen, you can switch your touch keyboard layout by tapping or clicking the keyboard icon, and then tapping or clicking the keyboard layout you want to switch to.

How do you pull up the On-Screen Keyboard on a Chromebook? ›

Open the keyboard
  1. Sign in to your Chromebook.
  2. At the bottom right, select the time.
  3. Select Settings. Accessibility.
  4. Under "Keyboard and text input," turn on On-screen keyboard.

How do I bring up the On-Screen Keyboard on my Android phone? ›

When you tap on a text field, the keyboard should automatically appear [1]. Using the three dots menu: In some apps, you can bring up the keyboard by tapping on the three dots menu (also known as the overflow menu) and selecting an option like "Keyboard" or "Input" [1].

How do I get the On-Screen Keyboard on my Android? ›

Open or close the on-screen keyboard
  1. Open your device's Settings app. .
  2. Tap Hub Mode. At a glance. Search your tablet.
  3. Turn on Always show keyboard.

Top Articles
Latest Posts
Article information

Author: Mrs. Angelic Larkin

Last Updated:

Views: 5682

Rating: 4.7 / 5 (47 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Mrs. Angelic Larkin

Birthday: 1992-06-28

Address: Apt. 413 8275 Mueller Overpass, South Magnolia, IA 99527-6023

Phone: +6824704719725

Job: District Real-Estate Facilitator

Hobby: Letterboxing, Vacation, Poi, Homebrewing, Mountain biking, Slacklining, Cabaret

Introduction: My name is Mrs. Angelic Larkin, I am a cute, charming, funny, determined, inexpensive, joyous, cheerful person who loves writing and wants to share my knowledge and understanding with you.