How to reconfigure a keyboard

at 15 November 2007

Recently we held an the introductory R-course. In R you need to use the tilde (~) sign often. Everytime you specify a statistical formula, you write something like:



Y ~ Treatment + X



One of the participants had a keyboard on her (italian) laptop that had no '~' sign. As one of the participants could remember, that is no problem. You simply type the ASCII-code of '~' (126) on the numeric keypad while you hold down the 'Alt' key. And of course, on a laptop without a numeric keyboard you simply find the blue 'fn' key and the blue 'num lock' key and push them down simultaneously, then you type the ASCII code with the Alt key pressed, and then the blue 'fn' key and the blue 'num lock' key again. (If you forget the final part, 5t 5s act4a33y n4 *r6b3e0, s60e 6f the 2eys are s50*3y re*3aced w5th n40bers, oops - I meant to say, it is actually no problem, some of the keys are simply replaced with numbers).


The R-Help list had some discussion concerning this problem in 2004, where the solution above was suggested.

However, the satisfactory solution is to remap the keyboard. Microsoft has a utility program for doing this. You may download it from the Microsoft Keyboard Layout Creator. For Windows XP you probably need the old version (1.3), while Vista users can use version 1.4.


The instructions in the help menu are easy to follow. I'll just show a couple of screen dumps. First of all I load an existing keyboard via the File | Load existing keyboard option. I choose the Danish keyboard. The program then shows an image of the existing keyboard layout.





By selecting the different shift states, you may see the key mapping in the corresponding states. As an example, the AltGr shift state below.





In fact I have already changed the keyboard mapping. As you an see the keyboard now shows a '~' sign corresponding to the 'N' key. In order to obtain this mapping I simply clicked on the key in the screen image. A popup window allowed me to type the '~'-sign and he redefinition was made. (If your keyboard does not have the '~' sign you need to use the trick with the numeric keyboard and Alt 126 as described above).

Finally, you choose Project| Build DLL and setup Package, as described in Help file of the program. This produces an msi-file that can be executed and your new keyboard is installed.



So now I have a keyboard that produces a a tilde sign when I press AltGr+N. In contrast to the existing one (next to the Enter key in the right hand side) this one is not a dead key. I do not need to wait for another keypress to see the '~'sign.


Another option is to use e.g. AutoHotkey.

2 comments:

ewoomall keyboard said...

Very useful.I really appreciate your post.

Anonymous said...

There is another option like MapKeyboard (http://www.inchwest.com/mapkeyboard) that can easily remap your keys. I love using this on a laptop with a backlit keyboard because its easier on gaming. The pinky starts to hurt after awhile from pressing CTRL.