[Keyboard ]Solution Unsatisfactory

by Michael S. Kaplan, published on 2011/04/09, original URI: http://blogs.msdn.com/b/michkap/archive/2011/04/09/10151666.aspx

The other day, someone asked me for my thoughts on 'hacked' MSKLC to enable remapping CAPSLOCK.

This is the article over on the Colemak Forum from last year about the method they describe to perform the task of remapping the CAPSLOCK key in MSKLC-created keyboard layouts.

The method doesn't use hidden command line switches to MSKLC.EXE (there aren't tons of these there anyway).

It doesn't use hidden command line switches to KBDUTOOL.EXE (something several customizations I have mentioned in the past do).

It doesn't use special modifications to the .KLC file (something several other customizations I have mentioned in the past do), either.

What it does is give instructions to make specific modifications to the KBD.H header file (basically scrolling to a certain part of the file, the part for the "Type 4" keyboards, and replacing the word CAPITAL with the word BACK).

In case you ever wanted proof that a little knowledge is a dangerous thing, now you have it!

Allow me to explain.... :-)

I have talked about Keyboard Types before, in blogs like Knowing the layout doesn't mean knowing how to lay it out.... and the difficulties MSKLC and kbdutool have with it in particular in Had I known that my last release would be *the* last release..., aka hindsight is 2020.

As I mentioned in the latter blog, there is no direct way to control what keyboard type one will get when one creates a keyboard layout. So while type "4" -- IBM enhanced (101- or 102-key) keyboard -- is common, it is not the only one.

There are going to be times that this particular hack won't work at all (basically any time KBDUTOOL.EXE thinks it is another keyboard type that it is building)

And of course not all the hack's suggestions work, by the report of people there. For example, in looking specifically at the behavior of the special new CAPSLOCK that is now a backspace, Anders notes:

I tried this, while it does work... when you use the Caps Lock key repeatedly it only registers the backspace every second time.

Yes, this makes sense -- since the logic behind the key is not in the keyboard layout DLL itself; it is partly in the system's knowledge of the scan code that thinks of this key as a toggle switch (something the BACKSPACE definitely is not).

There are very few keys, in fact, that will seem like they behave properly when they have some of the "toggle key" semantic injected into their behavior. Unless they too are being used as a toggle of some sort.

Plus, I really like to avoid updating both SDK and WDK header files (KBD.H is a part of the WDK), because there can be unexpected consequences even beyond the ones I mention here if you try to build keyboards using the file.

One could use one's imagination and perhaps see programs that make CAPSLOCK/toggle key assumptions could themselves show errors, fail, or crash when they are given results that most closely resemble a Rubik's Cube that has been taken apart/had one side piece rotated 180°/put back together. You know, when you modify the cube so it can't ever be solved?

It believe it is even technically be a EULA violation, though I can't imagine it ever being enforced in this case, I mean unless someone tried to sue Microsoft for negative consequences of using a keyboard created by this means. In which case the use of the hack would be a pretty reasonable indemnification of Microsoft here, since someone delved into the land of the specifically unsupported....

So, my thoughts on 'hacked' MSKLC to enable remapping CAPSLOCK?

Clever idea, but it doesn't really solve the actual problem people want solved, which is that the CAPSLOCK key is sending information to the machine and keyboard layout DLLs are not designed to remap behavior fully (especially for the many keys that other parts of the system and other apps might try to make their own use of).

Similar problems can be seen in other keys as well, basically any key with special behavior beyond typing characters can have this kind of "baggage", and one key that just types a character yet still has special meaning (the VK_DECIMAL key, an issue I discussed previously in Who would win in a fight between VK_DECIMAL and LOCALE_SDECIMAL?.

To truly solve the full problem:

is required. A keyboard layout solution will always be incomplete since it cannot modify the scan code being sent....

comments not archived

go to newer or older post, or back to index or month or day