Fix wrong Keyboard Layout in Ubuntu

Is the Ubuntu Keyboard layout not working? Most Ubuntu users want to use their native language as the primary input language when using their system. Using the Ubuntu preferences utility, you can add your native language as a keyboard input source. This language can be configured to be used as the default keyboard layout. This layout means that anything you type on your keyboard will be perceived by your Ubuntu system based on the keyboard layout you choose.

This article describes how to customize the keyboard layout on the desktop to your preferred input language. It also describes how you can change it in the terminal (see the chapter on changing the keyboard layout on the Ubuntu server at the end of the article).

We have run the commands and procedures mentioned in this article on Ubuntu 20.04 and Ubuntu 22.04.

Change the Keyboard Layout in Ubuntu

There are two ways to change the Keyboard layout in Ubuntu. One is to use the Terminal, this method works on Ubuntu Server and Desktop. The other one is to use the GNOME keyboard configuration in the GUI, but this is limited to desktop systems. We will show you both ways in this tutorial. First, we start with the terminal method.

Use the Terminal to change the keyboard layout

Change the keyboard layout with this command on Ubuntu Server:

sudo dpkg-reconfigure keyboard-configuration

The keyboard-configuration wizard starts. It let you choose the physical keyboard type first:

Keyboard type

Next, you can choose the keyboard language:

Keyboard language

Then a dialog appears that lets you choose the layout of the keyboard:

Choose keyboard layout

Configure AltGr key.

Configure AltGr Key

Finally, the keyboard configuration wizard allows you to configure which key is used as compose key.

Configure Compose key

Keyboard configuration gets written to disk.

Writing keyboard config to disk

Add Keyboard Layout language as Input Resource

If you prefer using the GUI for performing simple administrative tasks, you can make of the graphical Settings utility.

You can access the Settings either through the system Dash or by accessing it as follows:

Click on the downward arrow located at the top-right corner of your Ubuntu desktop and then click the settings icon from the following view:

Click on Settings Icon

Alternatively, you can enter ‘settings’ in the Dash search to open the Settings directly.

Os search for settings in Dash

The Settings utility opens in the Wi-Fi tab by default. You need to click on the Region & Language tab in order to configure the keyboard layout.

This is how the Region & Language view looks like:

Ubuntu Settings

You can add another language for your keyboard layout by clicking the plus sign under Input Sources.

Browse to the language you want to add as an input source and select it.

Ubuntu Keyboard Layout

This will enable the Add button. Click the Add button after which your selected language will be added as an Input Source or a new Ubuntu keyboard layout language.

Ubuntu change keyboard layout

You can set the default input language by using the up and down arrows located under your list of Input Sources. The language at the top of the list will be used as the default keyboard language.

Please close the Settings utility.

Switch between Keyboard Layouts

After adding an Input Source, you will notice a Keyboard language selection icon on your Gnome top panel. You can expand it and select the default language to be used for the keyboard layout.

Switch Keyboard Layout

You can also click the Show Keyboard Layout button to get an idea about what input your system will take from the keyboard through different keys.

Alternatively, you can also use the keyboard shortcut Super(windows)+Space key to switch between Keyboard Layout languages.

Keyboard Shortcut to switch Keyboard layout

Your Ubuntu system will now consider the selected language as the new keyboard layout language from now on.