I am trying to remap some keys with xkb. In the below extract, I've changed two lines to configure my keymap. The one for space workes just fine. But both of the Delete
I mapped on BKSP
does not work, while BackSpace and AltGr+BKSP=BackSpace work as wanted.
I want to use Backspace
+Shift
as Delete
.
my /usr/share/X11/xkb/symbols/pc
file looks like this:
default partial alphanumeric_keys modifier_keys
xkb_symbols "pc105" {
key <ESC> { [ Escape ] };
// The extra key on many European keyboards:
key <LSGT> { [ less, greater, bar, brokenbar ] };
// The following keys are common to all layouts.
key <BKSL> { [ backslash, bar ] };
// key <SPCE> { [ space ] };
// user manipulated next line. this works and has nothing to do with my question.
key <SPCE> { [ space, space, bar ] };
include "srvr_ctrl(fkey2vt)"
include "pc(editing)"
include "keypad(x11)"
// key <BKSP> { [ BackSpace, BackSpace ] };
// user manipulated next line. This does not work and is relevant for this question.
key <BKSP> { [ BackSpace, Delete, BackSpace, Delete ] };
key <TAB> { [ Tab, ISO_Left_Tab ] };
key <RTRN> { [ Return ] };
key <CAPS> { [ Caps_Lock ] };
key <NMLK> { [ Num_Lock ] };
key <LFSH> { [ Shift_L ] };
key <LCTL> { [ Control_L ] };
key <LWIN> { [ Super_L ] };
key <RTSH> { [ Shift_R ] };
key <RCTL> { [ Control_R ] };
key <RWIN> { [ Super_R ] };
key <MENU> { [ Menu ] };
// Beginning of modifier mappings.
modifier_map Shift { Shift_L, Shift_R };
modifier_map Lock { Caps_Lock };
modifier_map Control{ Control_L, Control_R };
modifier_map Mod2 { Num_Lock };
modifier_map Mod4 { Super_L, Super_R };
// Fake keys for virtual<->real modifiers mapping:
key <LVL3> { [ ISO_Level3_Shift ] };
key <MDSW> { [ Mode_switch ] };
modifier_map Mod5 { <LVL3>, <MDSW> };
key <ALT> { [ NoSymbol, Alt_L ] };
include "altwin(meta_alt)"
key <META> { [ NoSymbol, Meta_L ] };
modifier_map Mod1 { <META> };
key <SUPR> { [ NoSymbol, Super_L ] };
modifier_map Mod4 { <SUPR> };
key <HYPR> { [ NoSymbol, Hyper_L ] };
modifier_map Mod4 { <HYPR> };
// End of modifier mappings.
key <OUTP> { [ XF86Display ] };
key <KITG> { [ XF86KbdLightOnOff ] };
key <KIDN> { [ XF86KbdBrightnessDown ] };
key <KIUP> { [ XF86KbdBrightnessUp ] };
};
hidden partial alphanumeric_keys
xkb_symbols "editing" {
key <PRSC> {
type= "PC_ALT_LEVEL2",
symbols[Group1]= [ Print, Sys_Req ]
};
key <SCLK> { [ Scroll_Lock ] };
key <PAUS> {
type= "PC_CONTROL_LEVEL2",
symbols[Group1]= [ Pause, Break ]
};
key <INS> { [ Insert ] };
key <HOME> { [ Home ] };
key <PGUP> { [ Prior ] };
key <DELE> { [ Delete ] };
key <END> { [ End ] };
key <PGDN> { [ Next ] };
key <UP> { [ Up ] };
key <LEFT> { [ Left ] };
key <DOWN> { [ Down ] };
key <RGHT> { [ Right ] };
};
Output of setxkbmap -print
:
xkb_keymap {
xkb_keycodes { include "evdev+aliases(qwertz)" };
xkb_types { include "complete" };
xkb_compat { include "complete" };
xkb_symbols { include "pc+de+gr(extended):2+ru(dos):3+us:4+inet(evdev)+ctrl(nocaps)+terminate(ctrl_alt_bksp)" };
xkb_geometry { include "pc(pc105)" };
};
xev output:
KeyPress event, serial 37, synthetic NO, window 0x6a00001,
root 0x13d, subw 0x0, time 2108465, (124,40), root:(1315,695),
state 0x10, 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 0x6a00001,
root 0x13d, subw 0x0, time 2108612, (124,40), root:(1315,695),
state 0x11, 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 0x6a00001,
root 0x13d, subw 0x0, time 2108707, (124,40), root:(1315,695),
state 0x11, 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 0x6a00001,
root 0x13d, subw 0x0, time 2108764, (124,40), root:(1315,695),
state 0x11, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
Right now with the manipulations I've made, pressing Backspace
+Shift
gives me a ~
.
I am using X11 and switch between german and us layout.
<BKSP>
is overwritten later on (or in another file, depending on which layout you are using)?. Please state as well more clearly what the key combinations should produce and what they are producing instead. You can usexev
from command line to check in detail how each key is being interpreted. Are u on x11 or wayland? – avila Mar 11 '21 at 12:29setxkbmap -print
– avila Mar 11 '21 at 12:33shift
+delete
(because shift is pressed in order to get the second level of the key. This is indeed annoying to fix, but there are pre-mate layouts that use exactly this configuration for the BKSP key (as/usr/share/X11/xkb/symbols/macintosh_vndr/apple
... maybe worth looking there to see how it is accomplished – avila Mar 21 '21 at 17:54