Normally, we have keyboards which have more than the normal keys. But, the general view is “Linux doesn’t support the extra keys”. True to some extent, it really doesn’t support all keys. But, there are a few keys which are detected by Linux, but it doesn’t know how to deal with them. Its something like, Linux detects the “electronic signal” generated by these keys, but it doesn’t have a mapping of the “signal” and “its name”.
We can specify this mapping and use those extra “signals” as keys. Every key generates a “signal” or a “keycode”. The command “xev” tells us the “keycode” of the key pressed.
Just run “xev” on konsole and press ‘a’, the output is…
KeyPress event, serial 30, synthetic NO, window 0×2200001,
root 0×40, subw 0×0, time 655687, (270,-143), root:(274,365),
state 0×0, keycode 38 (keysym 0×61, a), same_screen YES,
XLookupString gives 1 bytes: (61) “a”
XmbLookupString gives 1 bytes: (61) “a”
XFilterEvent returns: False
KeyRelease event, serial 30, synthetic NO, window 0×2200001,
root 0×40, subw 0×0, time 655780, (270,-143), root:(274,365),
state 0×0, keycode 38 (keysym 0×61, a), same_screen YES,
XLookupString gives 1 bytes: (61) “a”
Here we see that it says, the keycode is ‘38′. Linux has a mapping of 38 means ‘a’. Now, if I press “My Documents” button, this is what I see.
KeyRelease event, serial 30, synthetic NO, window 0×2200001,
root 0×40, subw 0×0, time 720180, (221,-246), root:(225,262),
state 0×0, keycode 239 (keysym 0xfed0, First_Virtual_Screen), same_screen YES,
XLookupString gives 0 bytes:
This says that it has a signal of 239, but no “mapping”.
We can specify mapping by creating a text file with the format
keycode {keycode} = {mapping}
The mapping is some string which identifies a key. There are some defined “mappings” which we can use. They are in the file, /usr/X11R6/include/X11/keysymdef.h
The known signals are already mapped to some code in that file. Like 22 is mapped to BackSpace. But, some of them like “XK_Next_Screen” are not mapped. We can use these “free codes” to map the new signals of our extra keys.
Hence, we can find the keycode of our extra key with “xev” and create a file,
~/.Xmodmap
and write something like…
keycode 239 = First_Virtual_Screen
keycode 237 = Next_Virtual_Screen
keycode 236 = Last_Virtual_Screen
Now, if we run “xmodmap ~/.Xmodmap, these new mappings get registered till we don’t restart X. So, we need to automate the running of this command on startup.
In KDE, open konqueror, GO->Autostart. Create new link to application, and type the execution command as “xmodmap .Xmodmap”. Now, it will work even after restarting X.
Also, first select the correct Keyboard Model in Control Centre->Regional and Accesibility->Keyboard Layout. If you do this, some of the extra keys “automatically” start working.
Have fun!