Keyboard in X II - Using the 'Windows' Keys

Navigation : \\ Next page : \\ \\ Section Index - Knowledge Base Index

Section index - KB index

Most window managers and environments allow using the '~WinKeys' as modifiers (that is in combination with other keys) to configure keyboard shortcuts for all kinds of actions, and there is no further modification necessary.

If the configuration utility for your window manager or environment does not seem to recognize these keys, you should first check the key map with:

xmodmap -pk | grep 11{567}

115, 116 and 117 are the usual keycodes for the 'windows keys' (from left to right). Unless you are running KDE, you should get something like this:

115         0xffe7 (Meta_L)
116         0xff20 (Multi_key)
117         0xff67 (Menu)

If the right hand column is empty, check '/etc/X11/XF86Config-4' (as 'root') for the

entry. This entry should be set to either

If everything's correct and it still doesn't work (or not the way you want to), you have to set the bindings by hand, don't worry, it's not that difficult.
This can be done via the 'xmodmap' command. Create a file in your home directory called '.Xmodmap'. The most simple case for the Windows keys would be mapping them to function keys. To avoid conflicts with existing mappings, use F13, F14 and F15:

keycode 115=F13<br> keycode 116=F14<br> keycode 117=F15

Save this file and run

xmodmap .Xmodmap

Now return to your manager's shortcut configuration utility. Using the provided 'grab' function, press the keys, and you should see the appropriate mapping appearing in the utility.

Mandrake Linux seems to have tried to achieve a similar thing, first via patching '/usr/bin/startkde' directly and in 8.1 and later with the '/usr/bin/test-windows-key' script and the 'DISABLE_WINDOWS_KEY' option in '/etc/sysconfig/keyboard'. Their solution however does not work for me:

  • The right 'flag' key isn't mapped.
  • The mapping of the menu key (117) to 'menu' in 8.1 and later confuses KDE and GNOME (at least with a German key map): the left 'flag' key (115) now appears to be the menu key, whereas the menu key is blocked. So I'm left with effectively one additional key ...
As for the question if you can use the 'flag' keys as modifier keys (i.e. like in Windows in key combinations): of course you can :-). The appropriate mapping in '~/.Xmodmap' looks like this:

keycode 115 = Meta_L<br> add mod4 = Meta_L<br> keycode 116 = Meta_R<br> add mod4 =Meta_R

Et voila, another modifier key1.1 Using these keys as modifiers has a huge advantage: no Linux application uses them by default. This means you are totally free to create shortcuts using these keys without having to be afraid to collide with preset application shortcuts. And yes, that's the setup I'm using ;-).

section index

Related Resources:

man xmodmap
man xev

Revision / Modified: June 13, 2002
Author: Tom Berger

Legal: This page is covered by the GNU Free Documentation License. Standard disclaimers of warranty apply. Copyright LSTB and Mandrakesoft.

Kreinto: AdminWiki on 2004/03/22 09:45
(c) Mandriva 2007