For the past two years, I have been using the excellent Microsoft Natural Ergonomic Keyboard 4000 almost exclusively. This keyboard has a zoom slider in between the two main keys section that I just never use. I don't understand what the reasoning behind having a zoom slider instead of a vertical slider, but today we'll fix that for Ubuntu*.

Microsoft Keyboard: Natural Ergonomic Keyboard 4000

The easy way

  1. Open the /lib/udev/rules.d/95-keymap.rules file:

    $ sudo nano /lib/udev/rules.d/95-keymap.rules

  2. Let's find the line that starts with ENV{ID_VENDOR}=="Microsoft". On my setup, it looks like:

    ENV{ID_VENDOR}=="Microsoft", ENV{ID_MODEL_ID}=="00db", RUN+="keymap $name 0xc022d zoomin 0xc022e zoomout"

  3. Replace the zoomin value with pageup and the zoomout value with pagedown:

    ENV{ID_VENDOR}=="Microsoft", ENV{ID_MODEL_ID}=="00db", RUN+="keymap $name 0xc022d pageup 0xc022e pagedown"

  4. After restarting your computer, the changes should be applied.

Fallback

If the above steps don't work, there's always the slightly messier way:

  1. Install evtest

    $ sudo apt-get install evtest

  2. We need to manually determine, which input event correspond to our keyboard's slider keys. For this, we will need to iterate the following command:

    $ sudo evtest /dev/input/event0

    • This will run the listener application.
    • We will press the slider keys until we get any type of response text. Mine looks like:

      
        Event: time 1352080012.017919, type 4 (EV_MSC), code 4 (MSC_SCAN), value c022d
        Event: time 1352080012.017924, type 1 (EV_KEY), code 104 (KEY_PAGEUP), value 1
        Event: time 1352080012.017948, -------------- SYN_REPORT ------------
        ^[[5~Event: time 1352080012.185892, type 4 (EV_MSC), code 4 (MSC_SCAN), value c022d
        Event: time 1352080012.185894, type 1 (EV_KEY), code 104 (KEY_PAGEUP), value 0
        Event: time 1352080012.185901, -------------- SYN_REPORT ------------
        

    • If nothing happens with event0, you need to close evtest and iterate trying different events (event1, event2, etc.) until we get a response. Mine worked with /dev/input/event3.
  3. Let's grab the keys' scan codes:

    sudo /lib/udev/keymap -i input/event3

    • Press the slider keys to grab their key codes:

      scan code: 0xC022D   key code: zoomin
      scan code: 0xC022E   key code: zoomout

  4. With the appropiate event in hand, we create a custom mapping file:

    $ sudo nano /lib/udev/keymaps/microsoft-keyboard-4000

    • Save and close the file (Ctrl+X, Y).
  5. Fill its content with the appropiate mappings:

    0xC022D pageup
    0xC022E pagedown

    • A complete list of available keymaps can be found here.
  6. Test the setup with:

    sudo /lib/udev/keymap input/event5 /lib/udev/keymaps/microsoft-keyboard-4000

  7. If everything went as expected, the final step is to permanently apply the change. For this we open the keymap rules file:

    sudo nano /lib/udev/rules.d/95-keymap.rules

  8. Right before the GOTO="keyboard_end" line, we'll place the following:

    ENV{ID_VENDOR_ID}=="045e", ENV{ID_MODEL_ID}=="00db", RUN+="keymap $name microsoft-keyboard-4000"

    • Save and close the file (Ctrl+X, Y).
  9. After restarting your computer, the changes should be applied.


* Heads up! This tip has been tested on Ubuntu 12.10.



blog comments powered by Disqus

Published

04 November 2012

Tags

Share

^ Back to Top