Editing Windows custom keyboard layouts

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.

Prerequisites

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.

Installing

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).

Workflow

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…)

MSKLC File

Editing

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.

MSKLC Edit

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’.

Dead Keys

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.

MSKLC DeadKey

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…)

MSKLC Project

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:

MSKLC Build

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.

Conclusions

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)

About Liviu Ionescu (ilg)
Hi! My name is Liviu Ionescu (ilg, ilegeul or eunete for colleagues and friends) and I’m a senior IT engineer. Or should I say a real programmer?

18 Responses to Editing Windows custom keyboard layouts

  1. Diana says:

    Very detailed article! I had a previous short experience with KLC, when I need Romanian diacritics.
    “Load existing keyboard” – it’s a very useful option, I didn’t notice before and it was unpleasant to redefine the keyboard.
    I have defined the diacritics using AltGr ([AltGr]+A=ă; [AltGr]+S=ş; [AltGr]+T=ţ;[AltGr]+I=î; [AltGr]+Q=â ).It wasn’t a suitable solution, for my laptop – where AltGr key is missing.

  2. The AltGr key can be replaced by the functional equivalent combination Ctrl+Alt.

    So, if your laptop has no AltGr, you can use the Romanian (Programmer) layout, and you’ll get a similar position of the Romanian letters.

    • Ed Miller says:

      My custom klc keyboard refuses to remain as the default keyboard in Windows 7. Every so often, Windows just reverts to using the standard international keyboard, so I have to reselect the keyboard I want to use (usually after writing some text that comes out wrong, so I have to go back and redo it). This gets very annoying. Any idea why this happens?

  3. Pingback: 2010 in review « ilg The Geek's blog

  4. Anand bhushan says:

    A great article. After a big search, finally landed to right article.

  5. gabyregistrado says:

    Great article!

    By the way, do you know how to edit the multimedia keys function
    –> I have a genius keyboard that has some keys like msn, favorites and more, wich I never use, but lacks something like volume up and down. Any suggestions?

  6. Maïeul says:

    I would like to make my own keyboard map in Windows to write old Greek with a keyboard of French Swiss.

    I use Microsoft Windows Keyboard Layout Creator.

    My actual code is on:

    https://github.com/grecromand/grecromand/blob/master/windows/grecromand.klc.

    My problem is with OEM_5 (l. 59), which I made dead key.

    In the test windows of MKLC, no problem : my key is dead, and I can combine it with another key. For example I press OEM_5 and after A (l. 49) and I obtain an alpha with psili (see l. 155)

    But when I make the official keyboard layout and try it in windows, it doesn’t run. When I press OEM_5, I obtain two consecutive psili…

    Do you have any idea what is wrong ?

    Thank a lot

    • Liviu Ionescu says:

      Unfortunately not, my experience with Windows specifics ended quite some time ago… :-(

  7. Pingback: Shift+2

  8. Pascal Bernard says:

    Great article!

    I’m making an arabic keyboard to match the keyboard found on this site http://www.lexilogos.com/clavier/araby.htm

    However, I am questioning myself how to do in order to get windows, or that program, to recognize a letter followed by an apostrophe –> ex:. س + ‘ in order to get the letter ش, or ت + ‘ in order to get ث

    Can this be made with the deadkey system, if yea, how?

    Thank you.

    • Liviu Ionescu says:

      Sorry, I no longer worked on that project, and I do not know how you can combine those letters, but I would look at how French diacritics are generated; if I remember right, they are also entered as sequences of several key, something like Alt-accent followed by letter.

      Good luck,

      Liviu

  9. Peremptor says:

    Unfortunately, this doesn’t work with my Win7 64bit Pro. It just keeps showing no keyboard at all.

    And I couldn’t find any other programm (only very expensive ones) that can create a fully functional keyboard layout. The old version 1.3 of KLMC doesn’t work correctly. For example, the remapped keys could be used in MS Word, but not in FireFox. Something’s very strange here -.-

    On Microsofts’ homepage it says 1.4 can be run on 64bit systems, but only in 32bit-mode. But there’s no explanation to this sentence.

    • Liviu Ionescu says:

      If the application was written for 32-bit mode, it usually can be executed in 32-bit mode on a 64-bit machine, but there are exceptions. I’m no longer using Windows for quite a while, so I’m afraid I cannot do much for this. :-(

  10. David Rogers says:

    The article is really first-class. However, I have a problem: At first I found that it was running with material on my attached backup drive; so I disconnected it. I have 2 layouts, which I thought were working, but now none have all the special characters that I created. I get an error: “There is a problem loading either keyboard; OK; then banner reads” Keyboard Layout Creator 1.4 – ‘Layout01 Description'”. No keyboard at all loads; I can not even get it to load a standard US from the list. Does anyone know how to delete all the old work so that I can start over, redefine the keyboard from scratch or just get one working (which only lacks 3 characters being correct)? I have uninstalled several versions, but that doesn’t help.

    Am running Win 7 Professional on a 64-bit Dell.

    Thanks for any suggestions.

  11. strapkass says:

    The easiest solution I have found for custom keyboard layouts on Win 8.1 is to use the Microsoft keyboard layout Creator 1.4 on another computer with an earlier operating system. Windows xp worked for me.

    After 5 hours of fiddling I came to the conclusion that Win 8.1 is incapable of building the appropriate files using the aforementioned software. It will allow you to load and modify keyboards but not save them.

    On the older computer Run the software and load an existing keyboard. Modify it to suit your needs. Under the projects tab, click the build function and save the files to a usb stick.

    Download and install Microsoft Keyboard Layout Creator 1.4 on your Windows 8.1 computer and then run setup from the saved files on your usb stick.

    It will load your customised keyboard straight to your keyboard toolbar at the bottom right of your screen. If you are using an earlier operating system than XP or Vitq you may have to download and install version 1.3

  12. Petar Petrenko says:

    I created my own keyboard layout with many other glyphs/characters using ALT, CTRL… But, when I started “Build DLL and Setup Package” I got a lot of warnings like:
    WARNING: The character ¥ (U+00a5) exists in the entry for VK_6, ShiftState ‘Ctl+Alt’ of the layout table and is not in the default system code page (1251) of the Macedonian (Former Yugoslav Republic of Macedonia) language you specified. This may cause compatibility problems in non-Unicode applications.
    Please, tell me what to do because I can’t compile the layout.

  13. I tried to use Microsoft Layout Creator, though I do not know how to show the numeric keypad in this program. I tried editing the source klc file, but I did not find documentation about the language.

    I am using US-International layout, and would like to press the “num pad less” (-) + shif return underscore (-)

Leave a comment