sponsor Vim development Vim logo Vim Book Ad

basic Tip #377: Microsoft Natural Multimedia Keyboard Scancodes

 tip karma   Rating 30/18, Viewed by 1709 

created:   November 27, 2002 0:55      complexity:   basic
author:   Jeremy Brand, B.S.      as of Vim:   6.0

I have collected most of the special keys' 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

--
Jeremy Brand <[email protected]>
http://nirvani.org/software/vim/

 rate this tip  Life Changing Helpful Unfulfilling 

<<A totally useless tip...or is it ? | Auto insert Java class template when editing a new Java file >>

Additional Notes

Anonymous, December 21, 2002 22:57
To actually 'use' the multimedia keys, its usefull 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!

  - Random contributor you dont care about
Anonymous, December 22, 2002 16:40
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.
If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
Sponsored by Web Concept Group Inc. SourceForge Logo