Microsoft Natural Multimedia Keyboard Scancodes
From Vim Tips Wiki
Tip 377 Previous Tip • Next Tip
Created: November 27, 2002 Complexity: basic Author: Jeremy Brand Minimum version: 6.0 Karma: 38/20 Imported from: Tip#377
I have collected most of the special key scancodes on the Microsoft Natural Multimedia Keyboard. This might be helpful for those of you that do lots of key-bindings.
http://nirvani.org/docs/Microsoft_natural_multimedia_keyboard_scancodes.html
[edit] Comments
To actually 'use' the multimedia keys, its useful to be able to map them with nmap or something. The easiest/best way to do this is to find the key's scancode via runing xev and pressing the key, looking at the scancode output, then doing a
xmodmap -e "keycode 139 = F13"
for example, replacing the 139 with whatever your special multimedia key's scancode was, and the F13 with whatever key you want, i used the F keys > 13 since my keyboard doesnt have anything above 12, and you can define upto i think 35 F keys (so i just mapped all my 'multimedia' keys to F13-F29 and then maped those F keys in vim to things i wanted to do, or to my windowmanager to do other stuff)
So thats a method that should work on any keyboard, and doesnt rely on special propriatary(sp) key layout stuff, but it does take a couple steps to get your scancodes n such. Here is what my .xinitrc looks like so i make sure and get all my keys mapped whenever i load X (i just put in the last lines that do anything, your X file may have some funny startup stuff it does)
Note the first two lines are me mapping my Caps Lock to the Escape key, so i dont have to make that horrible reach to the escape key to get outa whatever mode i am in. If you don want that, just dont have the top two lines (i just thought a few people might find that of interest)
xmodmap -e "remove Lock = Caps_Lock" xmodmap -e "keysym Caps_Lock = Escape" xmodmap -e "keycode 158 = F13" xmodmap -e "keycode 165 = F14" xmodmap -e "keycode 159 = F15" xmodmap -e "keycode 151 = F16" xmodmap -e "keycode 164 = F17" xmodmap -e "keycode 162 = F18" xmodmap -e "keycode 166 = F19" xmodmap -e "keycode 233 = F20" xmodmap -e "keycode 232 = F21" xmodmap -e "keycode 229 = F22" xmodmap -e "keycode 121 = F23" xmodmap -e "keycode 230 = F24" xmodmap -e "keycode 130 = F25" xmodmap -e "keycode 236 = F26" xmodmap -e "keycode 129 = F27" xmodmap -e "keycode 166 = F28" xmodmap -e "keycode 164 = F29" exec /usr/bin/wmaker
Hope that does someone some good. Again, to find out your scancode key, run the program
xev
then start hitting keys, and watch as stuff scrolls by, look for the keypress event as you hit a key, then look for the 'keycode' and thats the number you want!
With regards to xmodmap, you might find it tidier to put all your mappings into (e.g.) ~/.xmodmap and then call "xmodmap ~/.xmodmap" from ~/.xinitrc. Also, for those of you using xdm/kdm/gdm instead of startx/xinit, use ~/.xsession instead of ~/.xinitrc.
