Make the zoom slider of Microsoft Natural Ergonomic Keyboard 4000 and 7000 scroll up and down, in 14.04 (Trusty)

I tried to use this tutorial to make scroll switch work on my Microsoft Natural Ergonomic Keyboard 4000. But I face following error:

sudo: /lib/udev/keymap: command not found

I have udev version 204-5ubuntu20.2 (the version found in Trusty)

I noticed that this version doesn't include keymap tool. But I notices that greater udev versions (which available for Debian, for example) include this tool.

Could somebody explain this diff for me? =) And what should I do in this case - install package from Debian repo?


Ubuntu 15.10: I had no success with previous answers.

I have successfully used approach similar to the previous ones - instructions were mentioned in /lib/udev/hwdb.d/60-keyboard.hwdb.

I've created new hwdb file using sudo nano /etc/udev/hwdb.d/70-keyboard.hwdb containing:

# Microsoft Natural Ergonomic Keyboard 4000 - remap zoom in/out to page up/down
evdev:input:b0003v045Ep00DB*
 KEYBOARD_KEY_c022d=pageup
 KEYBOARD_KEY_c022e=pagedown

after that I've run

sudo udevadm hwdb --update
sudo udevadm control --reload

and replugged the keyboard and it worked.

For model 7000 use evdev:input:b003v045Ep071D*


If you look at /lib/udev/rules.d/60-keyboard.rules you'll see that everything has been messed around with. This is just part of the udev merger into systemd that has gone on.

All hardware rules are compiled into a binary hardware database. These follow a really strange format. The existing rules for keyboards that ship with udev live in /lib/udev/hwdb.d/60-keyboard.hwdb. Look at that but don't edit it (updates will probably overwrite it).

To add your custom rules, we'll create a new file in /etc/udev/hwdb.d/ by running sudoedit /etc/udev/hwdb.d/61-keyboard-local.hwdb. All you need to do is paste in the following -

If you are using the 4000 model:

keyboard:usb:v045Ep00DB*
 KEYBOARD_KEY_0c022d=pageup
 KEYBOARD_KEY_0c022e=pagedown

If you are using 7000 model:

keyboard:usb:v045Ep071D*
 KEYBOARD_KEY_0c022d=pageup
 KEYBOARD_KEY_0c022e=pagedown

This is adapated from the tutorial you posted so you might need to tweak based on your keyboard. Look at lsusb and make sure the vendor:product code above (as v####p####) is correct. It won't work if they don't match.

Once you're done editing, recompile the hwdb that udev uses:

sudo udevadm hwdb --update

And then you might need to re-plug. If it's a PS/2 keyboard you might need to reboot. In some cases you also need to reboot.


The original solution posted by Oli did not work for me, but it works after I changed the key numbers "0c022d" and "0c022e" to "c022d" and "c022e". I'm using a 4000 model, so I can't verify if the same change is needed for the 7000 model.

To repeat Oli's answer, here is what I did: create a new file by running sudo nano /etc/udev/hwdb.d/61-keyboard-local.hwdb. Paste the following lines to the file (for the 4000 model):

keyboard:usb:v045Ep00DB*
 KEYBOARD_KEY_c022d=pageup
 KEYBOARD_KEY_c022e=pagedown

After editing the file, recompile the hwdb that udev uses:

sudo udevadm hwdb --update

Then replug the keyboard.


Adding to Oli's answer, If you want line scrolling like how it is on a mouse, you can modify pageup/pagedown to up/down in your custom rule. Like:

keyboard:usb:v045Ep00DB*
 KEYBOARD_KEY_c022d=up
 KEYBOARD_KEY_c022e=down

Nice solution is here, and I can only add that you can map the keys to unused X keys like that:

$ cat /lib/udev/rules.d/95-keymap.rules
...
ENV{ID_VENDOR}=="Microsoft", ENV{ID_MODEL_ID}=="00db", RUN+="keymap $name 0xc022d katakana 0xc022e katakanahiragana
...

Proper names to use instead of katakana can be found here.

After reboot ;-) you can test that zoomin and zoomout keys are mapped successfully, and also to find out a proper names of the keys (to use in rc.xml for OpenBox WM, for example) using xev:

$ xev
...
KeyRelease event, serial 46, synthetic NO, window 0x3c00001,
    root 0x291, subw 0x0, time 1492891, (-261,-61), root:(573,380),
    state 0x0, keycode 101 (keysym 0xff27, Hiragana_Katakana), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False
...

Now you can connect new keys to completely arbitrary action. In my case of OpenBox window manager I used something like this:

$ cat <whatever>/rc.xml
...
<keybind key="Katakana">
  <action name="Execute">
    <command>volume_up.sh</command>
  </action>
</keybind>
<keybind key="Hiragana_Katakana">
  <action name="Execute">
    <command>volume_down.sh</command>
  </action>
</keybind>
...