Tag Archives: keyboard

Enabling zoom 'key' and spell key on Microsoft Natural® Ergonomic Keyboard 4000

The procedure is not best described elsewhere on the web. This article is a mess, too, but it works for me.

Keys need to be remapped to something under keycode 256 in order to work under X11.

  • Try using evtest and pressing keys to see what the keys map to right now.
    • evtest can will also tell you what are all the events supported by the device.
    • evtest will show two devices; you are interested in the second one (which exposes all the extended keys, such as new, reply, open, send, etc.
  • Use xev to see whether the keys are recognized, and as what are they recognized, in X11.

Now for the juicy part:

# put this into: /etc/udev/hwdb.d/61-keyboard-custom.hwdb

# then to update:
#  sudo udevadm hwdb --update && sudo udevadm control --reload-rules && sudo udevadm control --reload
# and:
#  sudo udevadm trigger
# or:
#  for i in /sys/class/input/* ; do if [[ -e "$i"/id/vendor ]] && [[ -e "$i"/id/product ]] && [[ "$(cat "$i"/id/vendor)" == 045e ]] && [[ "$(cat "$i"/id/product)" == 00db ]] ;  then echo $i ; echo change | sudo tee $i/uevent ; fi ; done

# Natural Keyboard 4000
# formerly:
:usb:v045Ep00DB*
# now:
evdev:input:b0003v045Ep00DB*
 KEYBOARD_KEY_0c01ab=finance             # KEY_SPELLCHECK    to KEY_FINANCE
 KEYBOARD_KEY_c022d=up
 KEYBOARD_KEY_c022e=down

We’re naming it 61-keyboard-custom.hwdb in order to have it come after /lib/udev/hwdb.d/60-keyboard.hwdb.

Instead of finance, up and down keys, try taking something from this list: quirk-keymap-list.txt — however, I am not certain how to determine which ones are under 256 except by looking at evtest‘s output.

You can map to keycode 255 and use xmodmap -e "keycode 255 = XF86ZoomIn" to map to a ‘proper’ zoom in key.

On a related note: If you want to remap scancodes to keycodes, you can do it on the fly using setkeycodes(8)

Some sources:


EDIT 2021-01-27:

  • Another useful resource is Arch Linux wiki’s article on mapping the scancodes.
  • Config files mapping from scancodes to X keycodes can be found in /usr/share/X11/xkb/keycodes. For instance, scancodes generated by evdev are in the file evdev in that directory.
  • Scancodes can be found using showkey — which only works from the virtual console, not from within X11.

OS X's Terminal: Getting Home, End, PgUp, PgDn to work

Apple’s Terminal on a Macbook requires a weird combination of fn+shift+left/right, fn+shift+up/down to get Home, End, PgUp and PgDn to work. And that still causes issues in a couple of places.

Despite maintaining my philosophy of “use defaults wherever possible”, I’ve decided to ditch iTerm and iTerm2 for a simple reason: after quitting from Apple’s Terminal, upon restart in Lion I get a screenful of information from my previous session. Quite handy if I had to restart a machine for some reason, but I don’t want to lose the context!

Here are two fixes found Francois Planque’s post.

First part involves fixing the escape sequences sent by the Terminal. Open Preferences (for example, by hitting Cmd+,), and navigate to Settings tab, then for the profile you want to adjust, navigate to Keyboard tab.

Over there, define the following escape sequences upon pressing home, end, page up and page down:

home: \033[1~
end: \033[4~
page up: \033[5~
page down: \033[6~

If you mess up something during input, use your mouse to hit the button “Delete one character”. To get \033 in the dialog box, just press the Escape key instead of typing backslash, zero, three, three.

After applying this, voila! vim and mc now type these keys correctly.

But, you’ve just messed up bash.

Second fix involves editing ~/.inputrc (or /etc/inputrc). Neither of these rc files existed on my machine. From Garret LeSage‘s blog post (and as suggested in a comment on Francois’s blog), I simply copy pasted the following:

"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e[3~": delete-char
"\e[2~": quoted-insert
"\e[5C": forward-word
"\e[5D": backward-word
"\e\e[C": forward-word
"\e\e[D": backward-word
set completion-ignore-case On

It’s nice to see an OS X-related tech post that’s still as useful in 2012 as it was in 2005. And it’s even nicer to see that it was originally intended for other UNIX and UNIX-style systems.

By the way: this post’s ID is 2 * 333. Make of it whatever you want. 🙂