Posts Tagged ‘Remap


Remapping keyboard keys on Windows

Looks like I have something against notebooks (or netbooks) with regular keyboards…
Recently I bought a second hand Sony netbook that a friend bought on Italy. Sincerely when I agreed to buy it I didn’t take into consideration that it could come with a rather strange keyboard and we usually tend to think that every keyboard will work as a US_International one… What a mistake.
First attempt was to map it as an ABNT2 keyboard and blindly type but it wasn’t that good. Next I tried setting language as portuguese and keyboard as italian (hoping dead keys would work)… another failure… that was time I tried to do the old trick my Lenovo had on Windows (something similar to what I used on Linux… but the fact is Linux has always dead keys… no matter what keyboard language you are using…) and this could only handle swapping keys but if my keyboard missed dead keys (as it missed at all I would never have dead keys with this trick).
Then I found the solution: The Microsoft Keyboard Layout Creator
The tool is described as:

The Microsoft Keyboard Layout Creator (MSKLC) extends the international functionality of Windows 2000, Windows XP, Windows Server 2003,and Windows Vista systems by allowing users to:

  • Create new keyboard layouts from scratch
  • Base a new layout on an existing one
  • Modify an existing keyboard layout and build a new layout from it
  • Multilingual input locales within edit control fields
  • Build keyboard layout DLLs for x86, x64, and IA64 platforms
  • Package the resulting keyboard layouts for subsequent delivery and installation

With this tool you can even get around the “missing curly braces limitation” of italian keyboards.
There is no secret on using it. First of all you pick up a keyboard to base your new one (or start from scratch but I suggest picking one as a template) by choosing the “Load Existing Keyboard” option under File menu, then you’ll be presented with a list similar to the one below:

Load Existing Keyboard

Load Existing Keyboard

After you pick up your template keyboard you’ll be presented with the screen where you can customize it. This screen presents you keyboard with a visual representation of a keyboard.

MSKLC Main Screen

MSKLC Main Screen

When you click any of the keys you’ll be presented with a short popup and a button where you can open the full customization screen.

Change Key Screen

Change Key Screen

This is where you provide new meanings for keyboard keys, in my particular case I had to change circumflex key from a simple key to a dead key. In order to do this I had to enable the dead key view in the window above and then define all the dead key possibilities.

Dead Key Mapping

Dead Key Mapping

Note that there is a standard of having the symbol composition with white space as the last one on the list (the tool will complain if it is not like that and I sincerely did not test without complying to this).
When you are done you only need to build the setup package and install on the desired machine.

Swapping Keys

If instead of a such a powerful tool you only need to simply swap one key by another, something as Lenovo did on the Windows XP bundled in my notebook.
While searching on the internet for some documentation on this I found this site which describes pretty well what you need to do even with samples but misses the whole scancodes list. The after some googling (and a few outdated link on MS site) I found this site that describes the remapping method and this one that has a word document with scancodes. Another handy tool for this job is an old tool from Visual Studio called spy++ but this tool is only supplied into paid Visual Studio versions.


Remapping keyboard on recent distros that use evdev+hal

As you may have read on the previous post my Lenovo 3000 C200 needs a “patch” for its keyboard on X since slash/question/degree key is in an unusual place.

After a little research (grep -r saved my day) I found out that the configuration that used to reside on /etc/X11/xorg.conf is now on /etc/default/console-setup so the same rule for overriding keymaps is still valid. The corresponding configuration for recent distros is something like this:


Recent update: If you want further explanation of the X keyboard configurations an excellent guide (and by the way the one I used to figure out this) is “An Unreliable Guide to XKB Configuration” by Doug Palmer (Also available here)


Remapping keyboard keys on X

I’ll share this tip since it took me some time to figure out this fix. I guess it is quite common in notebook keyboard to have such unusual layouts as mine (below):

The first impression I had when I bought this notebook was: “I guess slashes and question marks aren’t here on normal abnt2 keyboards…” but… Windows came bundled in my laptop and it was already remapped.

Then I installed Ubuntu (I guess it was 7.10 by the time) and for my surprise… the key seemed dead until I figured out that Right Control was missing… in fact my slash/question mark key was the right control. So I started a long research to find out how to fix this and after some research I discovered for both X and console. The solution is:

  • For X

Create a file under /usr/share/X11/xkb/symbols. I’ve named mine lenovo (guess why) and place this inside it:

partial modifier_keys
xkb_symbols "addslashes" {
key <RCTL> {  [ slash, question, degree ] };

Then modify your /etc/X11/xorg.conf and change XkbLayout section to this:

    Option        "XkbLayout"    "br+lenovo(addslashes)"

With this you override only this key from the original br keymap.

In order to find out the original key, in case you have a similar problem, run xev and have a look on the output. Mine looked like this (Control_R code confirms what I guessed, the key was in fact a Right control key):

KeyPress event, serial 34, synthetic NO, window 0x4a00001,
root 0x7a, subw 0x0, time 3139474, (430,712), root:(437,763),
state 0x0, keycode 105 (keysym 0xffe4, Control_R), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False

  • For Console keys

In order to change console keys you need to change the following file: /etc/console-tools/remap

and place the key changes there. It works like a file replace. So in order to make the same change I’d have this content inside it.

s/keycode  97 = Control/keycode  97 = slash/
/keycode  97 = slash/ashift keycode  97 = question
/keycode  97 = question/aaltgr keycode  97 = degree

For some weird reason, Ubuntu 7.10 and 8.04 wasn’t executing console remapping.

And at last, unfortunately this tip does not work anymore on upcoming Ubuntu 8.10 since it changed its key map control to use hal and evdev. So, I am back to where I was last year. If anyone by accident know how to do this in recent distros, please post a comment.


Blog Stats

  • 353,165 hits since aug'08

%d bloggers like this: