how to get Microsoft Natural Ergonomic Keyboard 4000's zoom slider (and other buttons) to work?
Solution 1
Create the file /etc/udev/rules.d/98-ms-ergo.rules
with the following contents:
ACTION=="remove", GOTO="keyboard_end"
KERNEL!="event*", GOTO="keyboard_end"
ENV{ID_INPUT_KEY}=="", GOTO="keyboard_end"
SUBSYSTEMS!="usb", GOTO="keyboard_end"
SUBSYSTEMS=="usb", IMPORT{builtin}="usb_id"
ENV{ID_VENDOR}=="Microsoft", ENV{ID_MODEL_ID}=="00db", RUN+="keymap $name 0xc022d pageup 0xc022e pagedown"
GOTO="keyboard_end"
This will map the zoom key to page-up/page-down without changing the installed files in /lib/udev
.
Once added, you just need to unplug and replug your keyboard for it to start working.
Solution 2
On Xubuntu 13.10 (perhaps on Ubuntu 13.10 too) the same can be done as follows:
Edit key mappings in /lib/udev/hwdb.d/60-keyboard.hwdb
:
###########################################################
# Microsoft
###########################################################
# Microsoft Natural Ergonomic Keyboard 4000
keyboard:usb:v045Ep00DB*
KEYBOARD_KEY_c022d=pageup
KEYBOARD_KEY_c022e=pagedown
Run
sudo udevadm hwdb --update
Reboot.
Solution 3
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:
lsusb
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 045e:00db
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:
evtest
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:
sudoedit /etc/udev/hwdb.d/61-keyboard-local.hwdb
Hit i
to activate the Insert mode and type the following:
keyboard:usb:v045Ep00DB*
KEYBOARD_KEY_70038=minus
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:
v
andp
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
KEYBOARD_KEY_
- The key name appears in lowercase in configuration file
- You can customize pretty much every key on your keyboard following this tutorial.
Solution 4
The problem is that evdev driver ignores keycodes > 255.
The solution, thanks to Marco Chiappero:
1) you have to define all the remappings that you need (in the form of "scancode keycode" list) and place them in a file under "/lib/udev/keymaps/" (for example I created logitech-lx710-cordless there). You can find the scancodes using evtest ("sudo evtest /dev/input/eventX", where X is your keyboard device. Be careful, sometimes these extra keys are exposed through a different device or your mouse interface: eg. event3 --> kbd, event4 --> mouse & extra keys). Here some sample output: Event: time 1294153475.909379, type 4 (Misc), code 4 (ScanCode), value c1028 "c1028" is the scancode value you're going to place in your keymap file, then pick up a number from input.h as described earlier and convert it to hexadecimal. Then write the remap pair in your file, maybe with a descriptive comment, like this: 0xC1028 0x9a # rotate button Iterate for every key > 255. 2) you have to tell udev to apply this remapping file everytime it encounters your keyboard, so edit the "/lib/udev/rules.d/95-keymap.rules" file adding the udev rule that matches your HW. Please don't ask me to define a rule for you. NOTE: you can immediately apply your keymap file by yourself typing "sudo /lib/udev/keymap /dev/input/eventX /lib/udev/keymaps/$YOUR_FILE" and verify it with evtest once again. Now, you can use the Gnome shortcuts editor to see that the keys are now usable inside X and create new shortcuts. However it might happen that no keysym is assigned to that keycode (so you'll see 0xXY instead of XF86Foo). You can see current mappings through xmodmap -pke, save the output into a file and edit it if you need (a full keysym code list is available in "/usr/lib/X11/XKeysymDB"). Once you added the keysyms to those keys you remapped, you can save this file as ~/.Xmodmap (or as /etc/X11/Xmodmap if you wish to apply to every user).
Related videos on Youtube
somasekhar
Hi, I am Martin Ueding, a physicist (Dr.), Machine Learning researcher and programmer. My areas of interest are natural language processing, theoretical physics, numerical methods and high performance programming. My strongest programming languages are C++, Python, R and Bash.
Updated on September 18, 2022Comments
-
somasekhar almost 2 years
I use a Microsoft Natural Ergonomic Keyboard 4000 on Ubuntu 10.10. The multimedia keys (Volume, Play/Pause) work, the Mail and Calculator button as well.
Now I would love to use the zoom slider, if it were possible I'd like to use page scrolling with that. Is there some way to enable that?
-
somasekhar about 13 yearsI figures out that the buttons I want are c022d and c022e, but I cannot find the input.h.
-
desgua about 13 yearsAs I understand (but I can't test because I don't have this hardware) you don't really need input.h, you just need to edit this file:
/lib/udev/rules.d/95-keymap.rules
. (May be here at launchpad you can find people with the same hardware therefore more able to help bugs.launchpad.net/ubuntu/+source/xorg-server/+bug/313514 ). Have you edited the file I mentioned above? -
Alain O'Dea almost 13 yearsThis is far too technical and disorganized an answer for most people. A few serious gaps: no help on determining the appropriate /dev/input/eventX, unclear steps mixed in with contextual information and requests not to ask for instructions for creating keymaps.
-
Alain O'Dea almost 13 yearsevtest isn't even installed by default making this even worse.
-
Alain O'Dea almost 13 yearsThrough trial and error I found that my keyboard is /dev/input/event3 and evtest doesn't pick up any events from the zoom slider.
-
Jason Plank over 12 years@AlainO'Dea Do you see two entries for it when you run
sudo evtest
? I tried scanning the first entry and it didn't pick up the slider events, but oddly enough on the second entry it picks them up fine. It reports code 418 for zoom in and 419 for zoom out. -
m_floer over 11 yearsRelated: shkspr.mobi/blog/2011/12/… (about enabling the zoom slider as an input and remapping it, such as to Cursor Keys Up/Down)
-
Amir Uval about 10 yearsWorked on 14.04 for me
-
Rubens Mariuzzo almost 10 yearsThis worked for me flawlessly using Fedora 19.
-
matanster almost 10 yearsFor the Microsoft Ergonomic 7000, the model appears to be 071d (as obtained by lsusb) rather than 00db - so if anyone tries this for 7000 they should probably replace 00db with 071d in the above file. Anyway in my case (Ubuntu 14.04), that doesn't work, maybe it's related to the fact
evtest
shows that the zoom slider doesn't trigger any event, unlike most other keys of the Ergonomic 7000 keyboard that do. Not sure about that as the Web/Home button does not show any output inevtest
either - although Ubuntu does pick it up. -
Michael over 9 yearsI can't get the 4000 to work on 14.04 either. Not seeing events in
xev
. -
Rubens Mariuzzo over 9 yearsTried this on 14.10, and didn't work.
-
Alrekr over 8 yearsMy 60-keyboard.hwdb had an existing entry for MNEK4K, with keyboard:usb:b0003v045Ep00DB*. Changing the actions did not work. Adding a new entry with those actions did work.
-
IdeaHat almost 8 years@Cocoabean
xev
doesn't work for me either. What does isevtest /dev/input/event3
. Ifevent3
doesn't have any reaction to this key, test with other events (event[0..9]
). -
Michael almost 8 years@Nicolás - That works! Awesome. Thanks for coming out and keeping the thread alive.
-
Pierre over 7 yearsWorked like a charm on 16.04. I used "up" and "down" (instead of resp. "pageup" and "pagedown") to get a smoother scroll when browsing web pages. Thanks a lot!
-
dmitry_romanov almost 7 yearsYou may map to
katakana
andkatakanahiragana
(or any other unused keycode from hal.freedesktop.org/quirk/quirk-keymap-list.txt ) rather than alias to existing keys. This way you can recognize and use the keys in combination with modifiers to toggle volume, language, size, etc (configure your window manager to enjoy two new super-keys).