Keyboard Mapping in Kubuntu 20.04: Fix Missing Symbols and Broken Keys

Illustrated infographic summarizing: Keyboard Mapping Kubuntu 20.04

By Greg Nowak. Last updated 2026-11-04.

A missing backslash key becomes surprisingly disruptive when you need to edit configuration files or run terminal commands. My original Kubuntu workaround came from using a Danish layout on a Thai keyboard: the physical keyboard lacked the key I needed for backslash. A sticking left Shift key created a second problem, so I reassigned Caps Lock to take its place.

Below is a more complete version of that setup, including how to identify your keys, apply the mapping, undo it, and reload it at login. For a business owner or agency team, the useful outcome is a workstation fix that another person can understand and maintain.

The short answer

For a missing symbol or a broken key in Kubuntu, start with the Keyboard page in System Settings: it holds the layout, its variant and the XKB options, and they work in both X11 and Wayland sessions. In an X11 session, setxkbmap does the same from a terminal:

setxkbmap -query    # current layout, variant and options
setxkbmap dk        # switch to the Danish layout
setxkbmap -option   # clear all XKB options again

Only when no layout, variant or option gives you the key you need is it worth writing the per-key Xmodmap file below.

Check your session before changing anything

These commands target X11. Run this in a terminal inside your desktop session:

echo "$XDG_SESSION_TYPE"

If it reports x11, continue below. If it reports wayland, start with Plasma’s keyboard settings. Xwayland provides compatibility for X11 applications within Wayland; an X11 mapping is therefore not a desktop-wide Wayland solution. See the official Xwayland explanation. An empty result needs further checking in your session information.

Also check the operating system’s age. Kubuntu 20.04’s release notes specify support through April 2023. In September 2026, treat this as a legacy workstation fix and plan migration to a supported release.

Situation Recommended approach
Wrong language or symbol positions Check the layout and variant in Plasma’s keyboard settings first.
A few missing symbols on X11 Test a small, documented Xmodmap file.
Broken Shift key on X11 Remap a replacement key and update the modifier map.
Wayland or frequent layout switching Use desktop keyboard options; investigate a suitable XKB configuration if needed.
Choose the method that fits the session and the problem before copying a mapping.

Identify the keys and save a recovery map

Keycodes describe what the system receives, not what is printed on the keycap. The numbers below belong to the original setup; verify yours with:

xev

Focus its event window, press each relevant key, and note the reported keycode. The original values were 49 for the key being repurposed for symbols, 50 for left Shift, and 66 for Caps Lock.

Before applying changes, save the current X11 map. Use a fresh filename if you already have a backup:

xkbcomp "$DISPLAY" "$HOME/.xkbmap-before-remap"

Keep the following recovery command available in an open terminal:

xkbcomp "$HOME/.xkbmap-before-remap" "$DISPLAY"

The xkbcomp manual explains the direction: a display as the source exports its map; a display as the destination receives the map.

Restore access to less-than, greater-than, and backslash

Create or edit $HOME/.Xmodmap in a text editor. Preserve any existing customisations. This is the original symbol mapping:

keycode 49 = less greater backslash backslash backslash

It assigns < and > to the first two positions and backslash to additional positions. Access to those additional symbols depends on the active layout and modifier configuration; do not assume AltGr will behave identically everywhere.

Apply the file using its full path:

xmodmap "$HOME/.Xmodmap"

Test the characters in a text editor before using them in commands. Check the unmodified key, Shift, and your layout’s alternate-level modifier. If backslash remains inaccessible, review the layout’s third-level selector or use an XKB-based adjustment.

Use Caps Lock as a replacement Shift key

If you also have the original hardware problem, add this block after verifying the keycodes:

clear Lock
clear Shift
keycode 50 = NoSymbol NoSymbol NoSymbol NoSymbol NoSymbol
keycode 66 = Shift_L NoSymbol Shift_L NoSymbol Shift_L
add Shift = Shift_L Shift_R

This removes the old Lock and Shift modifier assignments, disables the original left Shift, and rebuilds Shift using the replacement and right Shift. The xmodmap manual documents why modifier keys need these extra steps.

This assumes a conventional modifier setup and deliberately removes Caps Lock behaviour. Inspect existing modifiers with xmodmap -pm if you already have custom mappings. Skip this entire block if your Shift key works.

Reapply the file and test both Shift keys, shortcuts, and ordinary typing. A physically stuck key may still require repair; software remapping is a workaround within this session.

Make the mapping load at login

The original command below remains useful for exporting a working map:

xkbcomp "$DISPLAY" "$HOME/.xkbmap"

Saving this file does not make the mapping persistent. Something must reload your changes after login.

For this small setup, create $HOME/apply-keyboard-map.sh containing:

#!/bin/sh
[ "$XDG_SESSION_TYPE" = "x11" ] || exit 0
exec xmodmap "$HOME/.Xmodmap"

Make it executable:

chmod +x "$HOME/apply-keyboard-map.sh"

Open Autostart in System Settings and add the file as a login script. Labels vary by Plasma version; KDE’s Autostart documentation describes the mechanism. These mapping commands run as your normal desktop user.

Log out and back in, then test again. Also test after switching layouts or reconnecting a keyboard: those actions can replace custom mappings. If the setup repeatedly resets, investigate the keyboard configuration rather than adding arbitrary startup delays.

Leave a fix someone else can support

Record the keyboard model, layout, session type, changed keys, and recovery command. To undo this setup, remove its Autostart entry and restore the saved map. Remember that a desktop login script does not configure the pre-login screen.

If recurring workstation issues are interrupting delivery, talk to Greg about your setup. Bring the symptoms and current workaround so we can discuss a maintainable fix and a clear handover for your team.

Quick answers

Is there an xkbmap command?

No. setxkbmap sets the layout and options, xkbcomp exports or loads a whole keymap (the .xkbmap file above), and xmodmap changes single keys. All three are X11 tools.

xmodmap changes nothing

Run echo "$XDG_SESSION_TYPE". On wayland, which Plasma 6 starts by default, xmodmap reaches only X11 apps running under Xwayland, so use the Keyboard settings instead. On x11, a layout switch or a reconnected keyboard reloads the layout and drops the change: apply the file again, or let the login script do it.

Remap a key on Wayland

Use the layout, variant and XKB options on the Keyboard page in System Settings, which KWin applies to every app. For a key no option covers, a custom XKB layout file or a remapping daemon such as keyd works below the desktop, at the cost of more setup.

Find a keycode without xev

On Wayland, xev sees only its own Xwayland window. wev is the Wayland counterpart, and sudo evtest reads the keyboard device directly. evtest prints kernel key codes, which are 8 lower than the X11 keycodes xmodmap uses.

Related on GrN.dk

Need help with this kind of work?

Talk to Greg about your technical setup Get in touch with Greg.

Sources

Latest articles

Before scaling AI content, check the pages you already have. Verify claims, resolve overlapping coverage, and give WordPress reviewers control over publication.

Build a refund approval workflow in n8n and Stripe that shows reviewers the exact action, expires old approvals and tracks refunds through to completion.

A timeout can hide a successful job creation. Use stable operation IDs, destination API rules and a clear recovery process to prevent duplicate work.

Does your ChatGPT subscription cover website translation? Understand API credits, access and a WordPress workflow that turns approved Danish content into translation drafts.

An internal AI can keep quoting a deleted policy. Check document updates, indexed passages and cached answers to find where outdated guidance survives.

Codex drew all ten pages of my Ninjai comic from the script Claude wrote in the first test. What made that handover work, and what it cost.

ChatGPT delivered ten painted comic pages; Claude drew one page in code. A practical look at AI tool selection, creative briefs and approval decisions.

Get missing supporting documents under control with a clearly scoped AI workflow that sorts replies, coordinates reminders and gives the bookkeeper a clear follow-up list.

Know what dmesg and journalctl can tell you after a reboot, how to find previous-boot logs, and how to check that retention covers your investigation window.

Check how your chatbot identifies itself as AI, where requests for human help actually go, and what customers encounter when support is unavailable.