How to configure distinction between left and right Shift and Ctrl keys in KDE 6?
I want to configure language switching in KDE using different keys: English language with the left key, Russian language with the right key.
However, KDE 6 does not distinguish between left and right modifier key presses. When trying to configure keyboard shortcuts through the “Keyboard” section in standard “System Settings”, I only see Control and Shift - without distinction between left and right keys. This issue is observed in both X11 (openSUSE Tumbleweed) and Wayland (Fedora KDE Plasma Desktop - versions 42 and beta 43).
The xev utility correctly identifies left and right keys, so the problem is not with the hardware.
Is it possible to configure KDE (not suggesting GNOME and other environments) with Wayland (preferably) or X11/Xorg to distinguish between left and right modifier keys? If such a possibility exists, then how exactly is it implemented?
Configuring Left and Right Shift and Key Distinction in KDE 6
In KDE 6, configuring the distinction between left and right Shift and Ctrl keys can be done in several ways. The main solutions include using the xremap utility, configuring XKB keymaps, and using KDE’s advanced parameters.
Contents
- Main Solutions for Key Distinction
- Setup with xremap
- XKB Keymap Configuration in KDE
- KDE Advanced System Settings
- KDE Plasma 6.1 Features
- Method Comparison
- Conclusion
Main Solutions for Key Distinction
Several approaches are available for distinguishing between left and right Shift and Ctrl keys in KDE 6:
- xremap - a modern utility for key remapping that works with both Wayland and X11
- XKB keymaps - configuring system keyboard maps through KDE
- Advanced system parameters - built-in KDE capabilities for advanced keyboard configuration
Each method has its advantages and limitations, and the choice depends on your specific needs and technical skills.
Setup with xremap
xremap is a powerful utility written in Rust that allows you to remap keys and key combinations in Linux, including distinguishing between left and right modifiers.
Installing xremap
# For Fedora/RHEL/CentOS
sudo dnf install xremap
# For openSUSE
sudo zypper install xremap
# Or via GitHub for the latest version
curl -sSf https://git.io/Jqih7 | sh
Basic Configuration for Language Switching
Create a configuration file ~/.config/xremap/config.yml:
modmap:
- remap:
Shift_L:
to: Shift_L
Shift_R:
to: Shift_R
Ctrl_L:
to: Ctrl_L
Ctrl_R:
to: Ctrl_R
keymap:
# Switch to English on left Shift release
- Shift_L:
release:
setxkbmap us
# Switch to Russian on right Shift release
- Shift_R:
release:
setxkbmap ru
# Example of remapping left Ctrl to Hyper key
- Ctrl_L+Shift_L:
- to: Hyper_L
Running xremap
Add xremap to KDE autostart:
- Open “System Settings” → “Autostart”
- Click “Add Program”
- Specify the path to xremap and the path to the configuration file
The advantage of xremap is that it works at the Wayland level and can process key presses before they reach applications, providing system-wide remapping.
XKB Keymap Configuration in KDE
Method 1: Creating a Custom XKB Layout
- Open “System Settings” → “Input Devices” → “Keyboard”
- Go to “Layouts” → “Layout Settings”
- Create a new layout based on an existing one
To distinguish between left and right keys, you can create a custom XKB file:
# Create directory for custom symbols
mkdir -p ~/.xkb/symbols
# Create symbols file
cat > ~/.xkb/symbols/custom << 'EOF'
partial modifier_keys
xkb_symbols "custom_shift" {
// Left Shift for English
key <LSGT> {
type="ONE_LEVEL",
symbols[Group1]= [ Shift_L ]
};
// Right Shift for Russian
key <RALT> {
type="ONE_LEVEL",
symbols[Group1]= [ Shift_R ]
};
};
EOF
Method 2: Modifying System XKB Rules
- Create a rules file:
sudo mkdir -p /usr/share/X11/xkb/rules
sudo nano /usr/share/X11/xkb/rules/custom
-
Add your rules to the file.
-
Use the new layout in KDE:
- “System Settings” → “Input Devices” → “Keyboard” → “Add Layout”
- Select your custom layout
This method requires system privileges and may be more complex to configure, but it provides deep integration with the XKB system.
KDE Advanced System Settings
KDE provides advanced parameters for keyboard configuration:
- Open “System Settings” → “Input Devices” → “Keyboard”
- Go to the “Advanced” section
- Configure the settings:
- “Third-level selection key”
- “Shift key behavior”
- “Additional keyboard parameters”
To distinguish between left and right keys, you can use:
- Third-level selection key: assign Caps Lock or another key to access additional symbols
- Composite keys: configure combinations with Ctrl, Alt, and Shift
Note: In KDE Plasma 6, standard settings may not show the distinction between left and right keys, but advanced parameters offer more possibilities.
KDE Plasma 6.1 Features
In KDE Plasma 6.1, some issues with layout switching have been fixed:
- Ctrl+Shift now works correctly for switching layouts
- To configure, go to “System Settings” → “Input Devices” → “Keyboard”
- In the “Keyboard Shortcuts” section for layout switching:
- Remove the default combination from the “Main” section
- Add it to the “Alternative” section
Source: Reddit - CTRL-Shift for changing keyboard layout now works correctly in Linux
For your task with left and right Shift keys, KDE 6.1 provides a more stable foundation for working with layouts.
Method Comparison
| Method | Pros | Cons | Difficulty |
|---|---|---|---|
| xremap | Works in Wayland, flexible configuration, system-wide remapping | Requires installation, may conflict with other utilities | Medium |
| XKB keymaps | Deep system integration, works at kernel level | Requires system privileges, more complex to configure | High |
| KDE Advanced Settings | No installation required, integrated with KDE | Limited capabilities in Wayland, doesn’t always show left/right | Low |
Recommendation: For your task of switching languages with left and right Shift, xremap is the best choice because it:
- Works correctly in Wayland
- Allows precise configuration of each key’s behavior
- Doesn’t require deep knowledge of system files
- Is easily configured via YAML configuration
Conclusion
- xremap is the most effective solution for distinguishing between left and right keys in KDE 6, especially in Wayland
- XKB keymaps provide system-level integration but require more complex configuration
- KDE Plasma 6.1 improved layout switching, but additional tools are still needed for distinguishing left/right keys
- For your specific task (English - left Shift, Russian - right Shift), using xremap with a
setxkbmap-based configuration is recommended
Start with xremap setup - this will provide you with maximum flexibility and reliable operation in both sessions (Wayland and X11). If you encounter difficulties, you can consider creating a custom XKB layout for deeper system integration.
Sources
- GitHub - xremap/xremap: Key remapper for X11 and Wayland
- Reddit - CTRL-Shift for changing keyboard layout now works correctly in Linux
- KDE Discuss - How to use Super and Hyper as separate modifiers for keyboard shortcuts (Plasma 6 on Wayland)
- Unix & Linux Stack Exchange - How to customise keyboard mappings with Wayland
- Reddit - r/kde on Reddit: Can I remap keys within Plasma 6?
- Super User - How to remap CAPS LOCK on Wayland?
- KDE Discuss - Remap keys on plasma 6 wayland
- Paolo Mainardi - Mastering Key Remapping on Linux: A Practical Guide with xremap