Editing Windows custom keyboard layouts
May 31, 2010 17 Comments
My struggle with custom keyboard layouts dates back to the old CP/M days, whose support for localised keyboards was not even planned. When Windows first added support for local languages (was it Windows 95?) I thought the fight was over, but unfortunately it wasn’t so, and soon I had to edit the binary layout file to make it fit my needs.
Now, many years later, I faced once again the need to customise the Windows keyboard to match my new localised keyboard, and, to my surprise, Microsoft support made things a lot easier.
There might be many other third party tools available, but for a simple customisation, a free tool like The Microsoft Keyboard Layout Creator seemed enough.
According to Microsoft, the version 1.4 of this program runs on almost everything, from Windows 2000 to Windows 7, and requires .NET v2.0 to be installed.
Before using it, the program needs to be installed, so run MSKLC.exe with administrative rights (on Windows 7 you can run it as any user, you’ll be asked for the administrative password).
Using the program is straight forward. You can start with a completely new layout (File -> New), but usually you’ll just base your design on an existing layout, already installed (File -> Load Existing Keyboard…). When ready, save your layout as a .klc (File -> Save Source File As…) and on next sessions just load the existing .klc file (File -> Load Existing File…)
The idea is to define the Unicode codes to be generated for each combination of states, i.e. with shift, ctrl, alt.
For this just click on a key, and you get a small window where you can enter a single character. This character will be assigned to the current state, set by the left check boxes.
A more detailed view, containing input fields for all states, can be activated by clicking on ‘All…’ view.
A permanent setting to view all states can be set in Edit -> Options -> Show All Shift States By Default.
For keys that generate letters, be sure you check ‘caps = shift’, to make the key status follow the caps key.
You can get an even more detailed view of the settings, by activating the ‘Advanced View’.
A special feature is the possibility to enter accented letters in two steps, by first pressing a dedicated accent key and then the letter. This can be done by using ‘Dead Keys’, keys that apparently do nothing, but in fact prepare entering the accents.
As seen in the above table, be sure you define accented letter for both lower and upper case letters.
Building and Saving
When your layout is ready, save it to a local file (File -> Save Source File).
Then test if the layout works as expected (Project -> Test Keyboard Layout…)
Make further changes if needed, save the source file and finally build the final setup package (Project -> Build DLL and Setup Package). You’ll end up with a directory structured like this:
Notice: do not attempt to run the build procedure while the same layout is already installed, since the build will fail. First go to Control Panel and uninstall the keyboard layout.
Installing the new layout
To install this new layout on a Windows system, run the setup.exe file and follow the directions. On Windows 7 you can run it as a normal user, the setup will ask for the administrative password.
When done, go to Control Panel -> Region and Language -> Keyboards and Languages -> Change Keyboards and under your language, add the new keyboard layout.
In case the keyboard layout was already installed, go to Control Panel and uninstall it before running the setup.
Editing custom keyboard layout is obviously a minor, occasional task, but sometimes it can make a big difference in productivity.
For instance, virtualisation technologies offered Mac OS X users a convenient way of also running Windows programms. Unfortunately the localised Apple keyboards do not match the localised Windows keyboards, so using diacritics in a virtual Windows with an Apple keyboard can be quite tedious (for a possible solution, see this separate post).
Another case that I encountered was related to the difficulties of using localised keyboards layouts on a non-localised keyboard; without the letters properly painted on the keyboard, finding the new position of some characters on an usual keyboard can be confusing, and a more uniform layout can be easier to use (for details, see this separate post – TO BE DEFINED)