6

I'm playing around with keyboard settings, and wanted to remap my windows keys to tab, for convenience. So I tried (133 is the left super key on my keyboard)

xmodmap -e "keycode 133 = Tab Super_L"

but this didn't work, in that hitting the windows key still brings up the "windows" menu, and no tab is inserted. A few different variations on the same theme also didn't work, e.g. making the Tab happen on shift+super.

I'm using cinnamon (installed from a ppa on ubuntu 16.04) and lightdm, and I imagine that the windows/super key is being intercepted at a lower level, which xmodmap can't quite deal with...is there any way of achieving what I want? Answers not involving xmodmap are welcome!

(I'm far from an expert, so perhaps there's a very easy solution...)

2
  • 2
    Mixing modifiers and non-modifiers on the same key is tricky. You may need to run add or remove commands to set this up, or it may require going via XKB. – Gilles 'SO- stop being evil' Dec 6 '16 at 22:58
  • try something simpler like xmodmap -e "keycode 133 = a b" then check if key 133 writes a if pressed alone and b if pressed with Shift. If it doesn't, it means key 133 doesn't understand Shift and it probably needs to be TWO_LEVEL instead of ONE_LEVEL. – ewen-goisot Oct 21 '20 at 1:11
2

Trying to understand what's happenning

If I type xmodmap without argument (to get modifier list), I get:

xmodmap:  up to 4 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0x32),  Shift_R (0x3e)
lock        Caps_Lock (0x42)
control     Control_L (0x25)
mod1        Alt_L (0x40),  Meta_L (0xcd)
mod2        Num_Lock (0x4d)
mod3        ISO_Level5_Shift (0x69)
mod4        Super_L (0x85),  Super_R (0x86),  Super_L (0xce),  Hyper_L (0xcf)
mod5        ISO_Level3_Shift (0x5c),  Mode_switch (0xcb)

The important part is for mod4. That's where Super_L is.

Now, I run : xmodmap -e "keycode 133 = Tab Super_L" && xmodmap | grep mod4, and I get:

mod4        Tab (0x85),  Super_R (0x86),  Super_L (0xce),  Hyper_L (0xcf)

The mod4 line changed and added Tab. That's why your key 133 still open the window menu.

By the way, I'm trying this on I3WM so the results can be a bit different.
For example, if I press the key 133 on a terminal or text editor, it both write a tab and becomes a modifier.

I also noticed I don't have a different behavior with Shift because the type of the key is ONE_LEVEL.

You can also run xev | grep key to see what happens with some key combinations.

Solution

But xmodmap also tells you can't have more than 4 keys per modifier, so a solution (the only one that worked for me so far) is to sacrifice a key you don't use / don't have, make it become a Super_L.

If you use QWERTY, you can modify the layout located on /usr/share/X11/xkb/symbols/us (it's usually another file of the same folder if you're using another layout), and write:

key.type[Group1] = "TWO_LEVEL";
key <MENU>{[Super_L]}; // ONE or TWO level, assuming MENU key isn't used
key <LWIN>{[ Tab, Super_L]}; // should be TWO_LEVEL
key.type[Group1] = "ONE_LEVEL";

instead of (probably line 14 of the file)

 key <LWIN>{[Super_L]};

Then, update your keyboard layout with setxkbmap us && xmodmap | grep mod4.
You will get something like:

mod4        Super_R (0x86),  Super_L (0x87),  Super_L (0xce),  Hyper_L (0xcf)

If you still get Tab, you should probably sacrifice another key. Note that 0x85 is the hexadecimal value of 133, that mean this key will not be a direct mod4 but it still can behave like window key if Shift is pressed.

2
  • 1
    Appreciate the detailed answer, I had totally given up on this! It'll take me a few days before I have a chance to try this out, so I'm going to mark the answer as accepted for now, and if I have any additional feedback I'll come back and comment here once I've played around with this a bit more. – funklute Oct 21 '20 at 11:07
  • ok, no problem. Feedback are welcome and can help me to understand if the behavior is the same on another desktop. Do as you want. – ewen-goisot Oct 21 '20 at 11:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.