X11 solution:
Here and here I have found that the keycode for Capslock is 66. From here I've got the command to remap Caps Lock as Delete:
xmodmap -e "keycode 66 = Delete"
After testing that it worked I have made it run at startup by creating the file ~/.config/autostart/capslock-delete.desktop
(based on last link) with the lines:
[Desktop Entry]
Exec=sh -c 'xmodmap -e "keycode 66 = Delete"'
Name=capslock is delete
Terminal=false
Type=Application
It may happen that the Capslock key continues to trigger lock-uppercase beside doing delete. It needs to be disabled as said here, or in KDE, under keyboard settings - Advanced - Capslock behavior - Disable...
Update:
In case the solution of the said above desktop file or command to run at startup is not working, following this answer, this seems to work in Kubuntu 22.04:
create a file ~/.Xmodmap
containing the keycode
setting: keycode 66 = Delete
create a script like for example ~/bin/capslock.delete.sh
:
#!/bin/bash
sleep 1;
echo "running xmodmap"
xmodmap ~/.Xmodmap
make the .sh
file executable
add the same script file to be executed at startup
In case one still wants a key or key combination to lock the upper keys (the CapsLock key default behavior), the following command - involving xdotool
- which can be associated with shortcut like Super+Delete or Alt+Delete (where the key pressed for Delete is of course the real/former CapsLock) - will do:
xdotool key Caps_Lock
Install xdotool:
sudo apt install xdotool
I have associated Alt+CapsLock with the command sh -c 'xdotool key Caps_Lock'
.
(One would expect that xdotool
might be used in the first place to get the delete action with a command like: xdotool key Delete
, but that doesn't seem to work very well, as said here; I have been able to use it - sort of - with Ctrl+D, but that only deletes text to the right without deleting files.)
A good alternative to get the delete action (as well as others that I haven't tested) is to use AutoKey, described here, about the delete action:

Solution for Wayland:
I haven't tested because I don't use Wayland, but I have found here that xremap
and modmap
should work as alternatives to xmodmap
. Also, see the other answer on keyd
.
Delete
to<CAPS
). On a PC keyboard, that probably has to be changed in/usr/share/X11/xkb/symbols/pc
(key <CAPS> { [ Delete ] };
, but I have no idea where to change that for an apple keyboard. – vanadium Apr 28 '22 at 11:50