0

I did some research but I couldn't find a working solution: How can I make my keyboard buttons: KP_1, KP_2, KP_3 to work exactly the same as Shift_L, Alt_L and Control_L?

I use Linux Mint 17 Cinnamon.

I want the new keys to work in game Dota 2 (but i don't mind if they will work globally). I tried different things but none of it worked as expected:

xmodmap

I run in terminal:

xmodmap -e "keycode 87 = Shift_L"
xmodmap -e "keycode 88 = Alt_L"
xmodmap -e "keycode 89 = Control_L"

Results:

  • OS: KP_1 and KP_2 work as they should (as Shift and Alt), but somehow kp_3 doesn't work as Ctrl
  • Dota 2: none of the kp_1, kp_2, kp_3 work as Shift/Alt/Ctrl (why?)

remap.inc file

I added the following lines to /etc/console-setup/remap.inc

keycode  79 = Shift
keycode  80 = Alt
keycode  81 = Control

and then run

sudo dpkg-reconfigure console-setup -phigh

Results: doesn't work anywhere. I don't know why these keycodes are different than what "xev" returns, but that's what I found using dumpkeys:

sudo dumpkeys | egrep "^keycode.*KP_[123]"
keycode  79 = KP_1            
keycode  80 = KP_2            
keycode  81 = KP_3 

xbindkeys + xte

I addedd these lines to ~/.xbindkeysrc:

"xte 'key Shift_L'"
    Mod2 + KP_End

and ran "xbindkeys" in terminal.
Results: doesn't work anywhere (probably because Shift_L is pressed only once - I would like it to be kept pressing when I keep pressing KP_1, just like the normal Shift button).

1 Answer 1

3

If you want to map new keys as modifiers (like Shift, Ctrl, Alt), using keycode with xmodmap is not sufficient. You need to do something like:

keycode 87 = Shift_L
clear shift
add shift = Shift_L

keycode 88 = Alt_L
clear mod1
add mod1 = Alt_L

keycode 89 = Control_L
clear control
add control = Control_L

You have some examples in the xmodmap(1) man page. You can put these commands in a xmodmaprc file and run xmodmap xmodmaprc (instead of several xmodmap -e invocations).

3
  • It doesn't work in Dota 2 unfortunately (it works in os though). Any ideas why or how can i make it to work in other apps/games?
    – Kossak
    Aug 20, 2014 at 20:00
  • @Kossak Perhaps Dota 2 does low-level keyboard access, which would mean that any remapping would have no effect on it. In such a case, the only thing you might be able to do is to change the Dota 2 configuration if the keycodes are not hardcoded...
    – vinc17
    Aug 20, 2014 at 20:20
  • I would do it in the game itself but it doesn't have any option to rebind keys to Shift and Ctrl. In windows i just used external app for it (autohotkey) but it works only on windows.
    – Kossak
    Aug 20, 2014 at 21:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .