I want to change the key mapping of Shift+Backspace to Delete.
Running xmodmap -pke
gives me (among other lines):
keycode 22 = BackSpace BackSpace BackSpace BackSpace BackSpace BackSpace
I change this line to
keycode 22 = BackSpace Delete Delete Delete Delete Delete
and save it in the file ~/.Xmodmap
and run xmodmap ~/.Xmodmap
. Apparently, this worked in part. When I run xev
and press Shift+Backspace I get:
KeyPress event, serial 37, synthetic NO, window 0x1200001,
root 0x300, subw 0x0, time 133664788, (484,630), root:(584,799),
state 0x0, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyPress event, serial 37, synthetic NO, window 0x1200001,
root 0x300, subw 0x0, time 133665052, (484,630), root:(584,799),
state 0x1, keycode 22 (keysym 0xffff, Delete), same_screen YES,
XKeysymToKeycode returns keycode: 119
XLookupString gives 1 bytes: (7f) ""
XmbLookupString gives 1 bytes: (7f) ""
XFilterEvent returns: False
KeyRelease event, serial 37, synthetic NO, window 0x1200001,
root 0x300, subw 0x0, time 133665116, (484,630), root:(584,799),
state 0x1, keycode 22 (keysym 0xffff, Delete), same_screen YES,
XKeysymToKeycode returns keycode: 119
XLookupString gives 1 bytes: (7f) ""
XFilterEvent returns: False
KeyRelease event, serial 37, synthetic NO, window 0x1200001,
root 0x300, subw 0x0, time 133665444, (484,630), root:(584,799),
state 0x1, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
With other modifier keys (LeftAlt, RightAlt, LeftCtrl) I still get BackSpace.
But xev seems to be the only application that recognizes Delete. In Wayland applications I get only Backspace, no matter what modifier key (Shift, LeftAlt or RightAlt, LeftCtrl) I press. In Firefox (an X application) there is a change. Now, Shift+Backspace does nothing. I suppose this is because Shift+Delete does nothing as well. The KeyPress event of Shift_L seems to block Delete from being obeyed by applications, which is unfortunate when Shift is part of a key combination that maps to Delete. How can I undo this block of Delete? How can I make the key mapping work in Wayland and X applications?
Try keyd or kmonad. I do all my key mapping on the keyboard itself, so I can’t vouch for either.
https://discuss.kde.org/t/remap-keys-on-plasma-6-wayland/15215/3
+1 on keyd. Only program that worked well for me on wayland
xmodmap was mean to work with x11 so it shouldn’t be a surprise that it doesn’t work very well w wayland.
instead, you’ll want to use a combination of libinput and evdev along w gnome/kde tools or input-remapper/wlr-inputremapper if you’re not using either.
My approach is to define custom keymap and enable it in xinitrc. Might be worth a try though I’ve no idea how that interacts with Wayland.
I read about this method of changing key mappings of your keyboard layout in the
/usr/share/X11/xkb/symbols/
directory. I think this is basically what you do. In these files there are only symbols and “partial alphanumeric_keys” defined. I don’t see how keys like backspace can be redefined there. But I will look further into it.Yes. I’m just keeping the symbols file in home directory so that I don’t have to edit the system files. To change backspace you’d have something like the following I believe:
key <BKSP> { [ BackSpace, Delete ] };