Remapping keys of Microsoft Natural keyboard

Use xev to get keycode and name (note that these key codes differ from when using showkey -k when not in X).

Forward key…

KeyPress event, serial 27, synthetic NO, window 0x3a00001,
    root 0x3e, subw 0x0, time 3026042600, (107,-95), root:(365,188),
    state 0x10, keycode 233 (keysym 0x0, NoSymbol), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 27, synthetic NO, window 0x3a00001,
    root 0x3e, subw 0x0, time 3026042768, (107,-95), root:(365,188),
    state 0x10, keycode 233 (keysym 0x0, NoSymbol), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

Back key…

KeyPress event, serial 27, synthetic NO, window 0x3a00001,
    root 0x3e, subw 0x0, time 3026041000, (107,-95), root:(365,188),
    state 0x10, keycode 234 (keysym 0x0, NoSymbol), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 27, synthetic NO, window 0x3a00001,
    root 0x3e, subw 0x0, time 3026041272, (107,-95), root:(365,188),
    state 0x10, keycode 234 (keysym 0x0, NoSymbol), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

(Btw, use xmodmap -pke to view key map.)

Remap keys…

xmodmap -e "keycode 233 = Right"
xmodmap -e "keycode 234 = Left"

Add the following to /etc/X11/xinit/xprofile (for system wide) or ~/.xprofile (for user) to make permanent:

xmodmap -e "keycode 233 = Right" &
xmodmap -e "keycode 234 = Left" &

Don’t forget the ampersands.

The Forward key will now send Right and the Back key will send Left.

Refs:

  • http://www.columbia.edu/~djv/docs/keyremap.html
  • http://blog.psuter.ch/?p=55
  • http://gentoo-wiki.com/TIP_Run_Commands_at_X_Startup

Last modified: 07/12/2007 Tags: ,

This website is a personal resource. Nothing here is guaranteed correct or complete, so use at your own risk and try not to delete the Internet. -Stephan

Site Info

Privacy policy

Go to top