If you've defenestrated your computer, you're doubtlessly annoyed that you now have 2 useless "Windows keys" on your keyboard. Come to think of it, you probably don't know what they do on Windows! But if you're using XFree86 (as supplied with Linux, FreeBSD, NetBSD and maybe even Solaris x86), you can make use of them!

Make up a file named .xmodmaprc in your home directory, and insert these lines into it:

! Set up "super" keys on PC keyboards
keycode 115 = Super_L
keycode 116 = Super_R
add mod4 = Super_L Super_R
Run "xmodmap ~/.xmodmaprc", or (even better) arrange in your .xsession or .xinitrc to run this command every time you start X. Now the 2 windows keys will generate "Super" shift codes. But how can you use them?

Well, recall that Emacs stands for "Escape Meta Alt Control Super" (hyper shift is also sometimes defined). Surely you have some use for doubling the number of key combinations!

For instance, I usually bind "Super-z" to iconify-emacs, rebinding "Control-z" to iconify-frame. None of the super-keys are bound by default, so they're all free for you to use!

Note: Some keyboards may generate different codes; use xev to check if yours is one of them (run the program, move the mouse cursor to the window, and press each of the keys several times, observing the output to know the keycode. Substitute these values for "115" and "116" above.

It seems that 115 and 117 are more common. And of course, you don't have to use them just for XEmacs - you can make them do stuff in your desktop or window manager.

I have bound left-window to Super, right-window to Compose, and menu to Hyper. XEmacs has been configured to lots of Hyper-key combinations; my window manager (fvwm2) uses Super-key combinations almost exclusively. Thus the window manager is more or less completely controllable from the keyboard, without interfering with programs that want meta keypresses. And, of course, you can never have too many keybindings in Emacs.

For reference, here are the relevant bits of my .Xmodmap:

keycode 115=Super_L
keycode 116=Multi_key
keycode 117=Hyper_R

add mod2 = Super_L
add mod3 = Hyper_R

Depending on your keyboard and your X settings, you may need to specify key codes other than 115, 116, and 117. To determine what key code X is generating for these keys, run xev and press the key. You should get something like:

KeyRelease event, serial 19, synthetic NO, window 0x6400001,
    root 0x26, subw 0x0, time 597817457, (-204,666), root:(849,689),
    state 0x0, keycode 115 (keysym 0x0, NoSymbol), same_screen YES,
    XLookupString gives 1 characters:  ""

The number following keycode is what you need to use.

Also, you may need to make Super mod4 instead, depending on whether you have num lock mapped to mod2. Me? I have my num lock key mapped to something else entirely.

Evidently, not all keyboards are created equal. My keyboard, for example, produces keycode 125 for the left windows key, 126 for the right windows key, and 127 for the "menu" key.

If you want to know what key produces what code, su and run showkey. Every time you press or release a key, it will tell you exactly what scancode is produced.

Log in or registerto write something here or to contact authors.