SuSE Linux: All versions
Basically, these keys work like all other keys on the keyboard. However, there is no suitable table that 'translates' these special keys to the desired function. Nevertheless, the Linux kernel uses two such tables. The first one translates the scancode generated by the keyboard to a so-called keycode, which in turn is transformed to the actual keyboard layout by means of an additional, country-specific keymap which can be loaded by the user.
As the special keys generate unknown scancodes, unfortunately you have to change both tables. The step-by-step procedure is described below.
Currently, the procedure described below can only be used for the text console. Due to the special handling of the keyboard by the X server, these settings can't be adopted under X.
Proceed as follows in order to utilize the additional keys in the console.
First of all, find out which special key generates which
scancode. You can do this with the help of the command showkey
-s
. Successively press all special keys (the generated code of
which usually begins with 0xe0) and make a note of the code. This is
what the result should look like:
erde:~# showkey -s kb mode was XLATE press any key (program terminates 10s after last keypress)... 0x9c 0xe0 0x25 0xe0 0xa5 0xe0 0x26 0xe0 0xa6 0xe0 0x32 0xe0 0xb2
In order to terminate the program, simply wait for 10 seconds without pressing any key. In the above-mentioned example, 3 special keys are pressed, and each key generates 2 bytes of code when the key is pressed and another 2 bytes when the key is released. You just need the value that is displayed when the key is pressed. By the way, the first value displayed by the program is the code generated when the Return key is released ...
Accordingly, the following codes can be extracted from the above example:
0xe0 0x25 for the 1. keyBy means of e.g. a shell script, you can allocate these to so-called keycodes. The keycodes 112-125 are not employed by any other keys and may be allocated freely to special keys. This is done by means of the following commands.
setkeycodes e025 112 setkeycodes e026 113 setkeycodes e032 114
From now on, the kernel will generate the respective keycodes when the special keys are pressed. The respective functions must now be allocated to these keycodes through the second table.
You can do this by means of the keymap that is automatically
loaded by one of the start-up scripts in order to set the English (US)
keyboard layout when the system is booted. The keymap for the English
(US) keyboard can be found under the file name
/usr/lib/kbd/keymaps/i386/qwerty/us.map.gz
.
To modify the file, unpack it with the command gunzip
.
Check the manpages for the command loadkeys
and the file
keymaps
for allocating special functions to these
keys. In my example, I assign the keys F13 - F15 to these keys and
allocate a frequently-used command to a special key. For this purpose,
append the following lines to the keymap us.map
:
keycode 112 = F13 keycode 113 = F14 keycode 114 = F15 string F13 = "ls\n"
After loading the new keymap with the command
loadkeys us.mapYou can invoke the command
ls
by pressing the first defined
special key. In this way, you can freely allocate key functions (listed
in the manpage on 'keymaps') or entire character chains to all other keys,
which will subsequently be at your disposal on the console.