next up previous
Next: Keycodes Up: How to get your Previous: An example keyboard file


How to retrieve scancodes

Every key can be identified by its scancode. So if keyTouch wants to know what key you mean, it needs to know its scancode. This section describes how to find out a keys scancode.

First you have to download the program "getscancodes" from http://keytouch.sf.net . After you unpacked the downloaded archive, open a terminal program (like xterm, konsole or gnome-terminal) in the unpacked directory. If you are not using a PC (which means an x86 system), you will have to compile the program for your system by running the command "make".

The "getscancodes" program makes use of the evdev driver. So the first step is to load the evdev module. Run the following command in your terminal program to load the evdev module:

$ su -c "/sbin/modprobe evdev"
(do not type the $ character) Fill in the root password and press enter to load the module. If you are using Ubuntu (or another sudo based distribution) you will have to run:
$ sudo /sbin/modprobe evdev
When you now look in the directory /dev/input/ you will notice that there are some files (devices) called "eventX" (where X is replaced by a number). To see the contents of /dev/input run:
$ ls /dev/input
Every event device (like a keyboard or a mouse) is related to one of these files. To find out which file belongs to your keyboard, run:
$ su -c "./getscancodes /dev/input/eventX"
Or under Ubuntu:
$ sudo ./getscancodes /dev/input/eventX
Replace the X by a number. getscancodes will first show some information about the device, including its name ("Input device name") that can tell you if you have chosen the correct event device. Press one of the extra function keys to see if getscancodes reacts on it. If not, try another event device. When you finally have found the correct device we are ready to retrieve the scancodes. Just press the key and getscancodes will show the scancode (after releasing the key, the scancode will be printed again). For example:
146 (0x92)
The number in brackets is the hexadecimal representation of the scancode. We only need the decimal value for our keyboard file.

To terminate getscancodes press Control+C.


next up previous
Next: Keycodes Up: How to get your Previous: An example keyboard file
Marvin 2005-10-15