In order to configure the Microsoft ergonomic keyboard 4000 we have to create a configuration file that contains the keyboard declaration and the records for mapping the keys.
To do so there are three types of information we need to determine:
- Keyboard type
- The key
scancode which is the actual key on the keyboard
- The key
name to assign the desired functionality to the selected key
First find the keyboard type:
In terminal run the following command:
the output determines the keyboard type:
Bus 004 Device 022: ID 045e:00db Microsoft Corp. Natural Ergonomic Keyboard 4000 V1.0
It appears after
ID. In this case it is
Second find the scancode and the name of the key.
To determine them, we use the
evtest program which logs out the event information of a specific device on terminal:
If you don't have the program, install it by running the following command:
sudo apt-get install evtest
By running the
evtest program we get the following output:
No device specified, trying to scan all of /dev/input/event* Available devices:
/dev/input/event0: Power Button
/dev/input/event1: Power Button
/dev/input/event2: PixArt USB Optical Mouse
/dev/input/event3: Microsoft Natural® Ergonomic Keyboard 4000
/dev/input/event4: Microsoft Natural® Ergonomic Keyboard 4000
/dev/input/event5: HDA Intel Front Headphone
/dev/input/event6: HDA Intel Line Out
/dev/input/event7: HDA Intel Line
/dev/input/event8: HDA Intel Rear Mic
/dev/input/event9: HDA Intel Front Mic
/dev/input/event10: HDA ATI HDMI HDMI/DP,pcm=3
Select the device event number [0-10]:
The output is pretty much self explanatory, insert the appropriate number for the keyboard, which here is number
3 then hit enter:
Doing so, will output lots of information on the terminal and ends in following lines:
Testing ... (interrupt to exit)
Event: time 1472203902.240594, type 17 (EV_LED), code 0 (LED_NUML), value 0
Event: time 1472203902.240594, -------------- SYN_REPORT ------------
Event: time 1472203902.281456, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70058
Event: time 1472203902.281456, type 1 (EV_KEY), code 96 (KEY_KPENTER), value 0
Event: time 1472203902.281456, -------------- SYN_REPORT ------------
Now with every key-press on the keyboard it dumps out the key information. For example the Slash key next to the Right Shift shows:
Event: time 1472205062.294078, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70038
Event: time 1472205062.294078, type 1 (EV_KEY), code 12 (KEY_SLASH), value 0
Event: time 1472205062.294078, -------------- SYN_REPORT ------------
The first line of the log contains the information about the actual key on the keyboard such as
scancode which comes after the value. In this case it is 70038
The second line contains the assigned functionality information like name of the key. In this case it is SLASH. Examine the other keys to find their appropriate names.
So in a nutshell:
- Our keyboard type is: 045e:00db
- The scancode of the Slash key is: 70038
- The name of the key for assigning is SLASH
After gathering the necessary information we create the configuration file:
i to activate the Insert mode and type the following:
Save and exit by pressing
escape then typing
:wq and hit enter.
Then run the following two commands for the configuration to take effect:
sudo udevadm hwdb --update
sudo udevadm control --reload
Finally unplug the keyboard and re-plug it in.
Some notes about the configuration file:
- The format of the file should be exactly as shown, the space before
mapping records is critical.
- Instead of
sudoedit you can use any other text editor, just remember to follow the exact format of the file as explained above.
- There are two characters added to the keyboard type:
p which stand for vendor and product. They are important as well.
- The keyboard type is written uppercase in the configuration file. Our keyboard type was 045e:00db but in the configuration we insert v045Ep00DB*
- The scancode of the key comes right after
- The key name appears in lowercase in configuration file
- You can customize pretty much every key on your keyboard following this tutorial.