[fix] Killing the F-Lock on MS Keyboards (even under USB)
None of the normal hacks to disable the F-Lock key on Microsoft keyboards work if you're connected via USB. The XML file at the end of this post corrects it.
Long story version
For some bizarre reason, the function keys (F1 through F12) on MS Keyboards have different meanings. I can't say it any better than Udolpho:
A few years ago Microsoft decided that something should be done with the function keys, F1 through F12, which sit at the top of every PC keyboard and have done so since IBM and God put them there in 1987. Microsoft decided out of the blue that the keys should be assigned arbitrary program actions, such as Undo, Redo, Open, Save, Reply, etc. Pressing F10 on Microsoft's newer keyboards starts the spell check routine, for example, if such a routine is supported by the application that currently has focus...
The most common key used is probably F5, labeled in virtually every Windows application as the Refresh key. It causes whatever window has the focus to redraw itself with up-to-date information. It's commonly used in browsers to refresh the web page. But refresh isn't even present on Microsoft's remapped keys; instead F5 is now the Open command, which means that in the most commonly used program it is entirely useless. And as with Word's spell check, the browser menu still tells you to use F5 to refresh. Well, don't bother.
This is especially annoying if you're developing software on Windows, since most development environments make heavy use of the function keys.
There is an F-Lock key on the keyboard which allows toggling the function keys to their proper behavior, but until recently it had to be hit every time you rebooted. They finally fixed it to remember the setting when you reboot, but... it only works when the keyboard is connected via the PS/2 keyboard port. Many newer computers (like mine) only have USB connections, which don't remember the F-Lock settings on reboot. Argh.
Jason Tsang wrote up some cool registry files to eliminate the F-Lock by modifying the keyboard scan codes, but sadly they don't work when the keyboard is connected via USB. Argh.
Udolpho came up with a workable solution which uses the Intellitype keyboard configuration software to map the F keys to a VBS script which calls SendKeys to send the correct key. This of course begs a question - if there's keyboard configuration software software, doesn't it allow configuring the F-Lock behavior? Nope. It has a lot of interesting options, but maddeningly doesn't allow configuring the F-Lock key behavior. So, anyway - Udolpho's solution works, but it's a pretty wild hack that requires manually mapping each key in the config software and running a VBS script every time you hit a function key.
I came up with a slightly simpler solution. I figured if Intellitype allows you to configure the key behaviors, it's got to store the configuration information somewhere. Sure enough, it's stored in a file called commands.xml. On my default installation, it's at C:\Program Files\Microsoft IntelliType Pro\commands.xml.
I made a backup of the commands.xml file and made a special version which maps the keys to the standard F-Key settings. This is a baby with the bathwater approach that probably kills some of the other special media buttons which I've never used; they're all in the commands.xml backup in case I ever want to hook them up. Anyways, here's the commands.xml file I came up with:
<?xml version="1.0" encoding="Windows-1252" standalone="yes" ?>
Copyright (c) 1983-2005 Microsoft Corporation. All rights reserved.
<C302 Type="5" KeySeq="F1" />
<C203 Type="5" KeySeq="F2" />
<C204 Type="5" KeySeq="F3" />
<C307 Type="5" KeySeq="F4" />
<C308 Type="5" KeySeq="F5" />
<C309 Type="5" KeySeq="F6" />
<C900 Type="5" KeySeq="F7" />
<C901 Type="5" KeySeq="F8" />
<C902 Type="5" KeySeq="F9" />
<C401 Type="5" KeySeq="F10" />
<C311 Type="5" KeySeq="F11" />
<C310 Type="5" KeySeq="F12" />
So, to set this up you just need to:
- Rename your commands.xml file (commands.xml.bak for instance)
- Create a new text file and edit it in Notepad
- Paste in the above text
- Save it as commands.xml in the same folder the old commands.xml file was in
- Test it - open IE, browse to a site, and hit F5. Did the page refresh?
Kinda hacky. If I get enough hits on this, I may put an installer together.