1

I want to remap my Tab key so when it clicked solely without any extra keys it will acts as Tab as usualy, but when I combine it with other keys like Tab+j it will behave like Win.

TAB = TAB (pressed solely)
TAB + (any_key) = WIN_KEY + (any_key)

Which tool I should use for this?

  • I haven't used it, but xcape sounds like exactly what you want – Fox Sep 19 '18 at 21:37
0

You need two command-line based tools, xev and xmodmap.

You can use xev to remap a key. Start the terminal window and run xev, then press the key whose behaviour you want to change. In your case the Tab key.

xev will show you information about the Tab key. such as:

 KeyRelease event, serial 37, synthetic NO, window 0x4000001,
    root 0x75, subw 0x0, time 4090453521, (461,542), root:(468,620),
    state 0x10, keycode 23 (keysym 0xff09, Tab), same_screen YES,
    XLookupString gives 1 bytes: (09) " "
    XFilterEvent returns: False

The third line is the most important, where Tab is the name of the behaviour the key is assigned to at the moment, the number keycode 23 is the internal id to recognize the Tab key.

or the information about the Windows key:

KeyPress event, serial 37, synthetic NO, window 0x4000001,
    root 0x75, subw 0x0, time 4090816069, (681,389), root:(688,467),
    state 0x10, keycode 115 (keysym 0xffeb, Super_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

Again, the third line is the most important, where Super_L is the name of the behaviour the key is assigned to at the moment, the number keycode 115 is the internal id to recognize Windwos key.

You can use xmodmap to swap two keys. Here is a tutorial. For example:

xmodmap -e "keycode 115 = Tab"

This will change the Windows key behaviour and make it behave exactly like a Tab key. or

xmodmap -e "keycode 115 = Tab j"

This will change the Tab+j key behaviour and make it behave like the Tab key.

0

@Goro in his reply listed good tools to recognize pressed key such a xev. But the second part of his answer wasn't what I was looking for.

I wanted to change the behavior of Tab not Windows key. For example to activate script in i3 window manager to change window I can press Tab + 1 to switch to the first screen. Win + 1 (default). But I can still use Tab to make an indention if I press it solely.

What I did to make it works was using xmodmap and xcape.

spare_modifier="Super_L"
echo $spare_modifier
xmodmap -e "keycode 23 = $spare_modifier"
xmodmap -e "remove mod4 = $spare_modifier"
xmodmap -e "add Win = $spare_modifier"
xmodmap -e "add mod4 = $spare_modifier"
xmodmap -e "keycode any = Tab"
xcape -e "$spare_modifier=Tab"

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.