How do I map key “Super” so, when combined with Left/Right, it produces keycode Home/End?
My current setxkbmap:
setxkbmap -model pc105 -layout 'us(dvorak-intl),us(alt-intl)' -option -option grp:lctrl_lshift_toggle -option compose:rwin
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You can’t do it with just a setkxbmap option, as no default option does what you want.
But you can do it by defining key behaviour at a lower level.
The page http://madduck.net/docs/extending-xkb/ helped me to understand and find a way to do it.
Create a file ~/.xkb/keymap/mykbd where you put the output of setxkbmap, it will be your base keyboard definition; eg:
setxkbmap -print > ~/.xkb/keymap/mykbd
then we will create a ~/.xkb/types/mytypes file and put the following in:
partial
xkb_types "super_level2" {
Virtual_modifiers Super;
type "SUPER_LEVEL2" {
modifiers= Super;
map[Super]= Level2;
level_name[Level1]= "Base";
level_name[Level2]= "Super";
};
};
it defines a type SUPER_LEVEL2 that will allow to easily define symbols sent when a key is pressed with Super.
then, in the ~/.xkb/symbols/mysymbols put the following lines:
partial modifier_keys
xkb_symbols "super_arrows_home_end" {
key <LEFT> {
type[Group1] = "SUPER_LEVEL2",
symbols[Group1] = [ Left, Home ]
};
key <RGHT> {
type[Group1] = "SUPER_LEVEL2",
symbols[Group1] = [ Right, End ]
};
};
(note the use of the “SUPER_LEVEL2 type we defined, it means that the second (level 2) symbol on the symbols line is triggered when pressing Super key (instead of Shift key).
Finally, edit the ~/.xkb/keymap/mykbd file to load the snippets we wrote:
- in the
xkb_typesline add+mytypes(super_level2)inside the quotes - in the
xkb_symbolsline add+mysymbols(super_arrows_home_end)in the quotes.
Now you can load it with
xkbcomp -I$HOME/.xkb ~/.xkb/keymap/mykbd $DISPLAY
Test your left/right keys, they should work as you wanted.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0