I want to use the Shift key as a dual-role key, for instance with the following two functions:

  1. normal Shift, e.g. left Shift + T results in capital 'T'
  2. as a \ key, i.e. if pressed and released without any additional key, it should print '\'.

Another example would be SandS, Space and Shift together .

Is that possible in Linux?


xcape (https://github.com/alols/xcape) allows to use modifier keys as shortcuts. the program runs as a daemon and should be auto-started in some way.

the syntax is simple, in my case it is

xcape -t 200 -e 'Shift_L=backslash;Shift_R=End'

symbols can be taken from http://wiki.linuxquestions.org/wiki/List_of_Keysyms_Recognised_by_Xmodmap, modifiers are the ones in xmodmap -pm (i suppose).

note that the daemon does not communicate to other instances, so in order to edit the setting, one has to kill the old one.

there is a forked package called ksuperkey, it's identical up to the default setting and an kde autostart file, which was used to kick of the kde menu. at the moment it seems like there are more ready-made packages for ksuperkey (tinyurl.com/jcagjxv), but in the future that might change, because it'll be replaced by an implementation in the kde window manager itself (tinyurl.com/hcbku6b)


Yes, only for X and not real terminal, you need to play with xev and xmodmap (install it if aren't in your default distro), those changes will dissapear after X logout, so you can persist them under your desktop init script configs.

Please check the answer found here: https://askubuntu.com/questions/24916/how-do-i-remap-certain-keys-or-devices

You can't easily remap keys on terminal because will follow keyboard map files from /usr/share/locale/* and isn't quite easy to modify, also, X uses a different keyboard mapping, but supports both usermode and system override of that. xev and xmodpam are user mode modifications, but you can create a xorg script at /etc/X11/xorg.conf.d/ under a InputClass section.

Hope it helps to solve your question!

  • 1
    please forgive me if i missed something, but the link does not explain how to make dual role keys.
    – Adam
    Sep 24 '16 at 23:15
  • in particular: i've seen that it's possible to add the shift function to any key. so i tried to set the shift key to '/'. now, when i press shift t, it prints '/T'. that is not what i want.
    – Adam
    Sep 24 '16 at 23:17
  • 1
    Oh my bad, you need to set a dead key, so you can use it as combo key (like control, alt and shift).
    – WalterCool
    Sep 24 '16 at 23:22
  • What the link say, you can start xev, press your combo keys with a dead key (ctrl+u, ctrl-k... etc), get the combination key code, and then do remapping of that keycode with xmodmap to do something other key
    – WalterCool
    Sep 24 '16 at 23:25
  • ok, i googled, but i could not find how to make shift a dead key
    – Adam
    Sep 24 '16 at 23:49

For those interested to have a "dual key" function without X, only on the CLI (Command Line Interface), there is a solution to use an appropriate keyboard. The advantage is that e.g. a dual key SPACE = CONTROL (if pressed together with another key) will work on all other OSs-computers you plug it in (MacOs, Windows, Linux...). For example the[UHK Keyboard can do this as part of their "UHK Agent" configuration software.][1] ( I am not affiliated with this company.) I just think this is a very straight forward solution. I have no knowledge of implementing a "dual role key" on the Command line Interface in Linux, and it seems there is non. At least not without much headache and tinkering.

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.