[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.
Type="5" KeySeq="F1" />
Type="5" KeySeq="F2" />
Type="5" KeySeq="F3" />
Type="5" KeySeq="F4" />
Type="5" KeySeq="F5" />
Type="5" KeySeq="F6" />
Type="5" KeySeq="F7" />
Type="5" KeySeq="F8" />
Type="5" KeySeq="F9" />
Type="5" KeySeq="F10" />
Type="5" KeySeq="F11" />
Type="5" KeySeq="F12" />

So, to set this up you just need to:

  1. Rename your commands.xml file (commands.xml.bak for instance)
  2. Create a new text file and edit it in Notepad
  3. Paste in the above text
  4. Save it as commands.xml in the same folder the old commands.xml file was in
  5. 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.


  • Hacky or not, it works. What is interesting is that the only keys on my MS keyboard that I have mapped to different functions is some added Multimedia buttons at the top. Like &quot;My Music&quot; I have mapped to my favorite playlist so it will open win WinAmp. Apparently those must be stored in the registry or a seperate file because your hack didn't overwrite them.

    Was your commands.xml file filled with over 2000 lines of application specific mappings? Because mine was, I am not sure what all that junk was, maybe some of it was from when I to Dvorak from Qwerty the other day. (I was bored).. Anyways..

    You da man, Jon! You Da MAN!

  • Yeah! Finally a fix for this stupid keyboard &quot;feature&quot;. I'm going to try this as soon as I get home to my PC.

  • Great Hacking !

    Finaly a solution !!!


  • the media keys use the standard (heh) microsoft extensions for that sort of thing - you can configure them in tweakui and maybe even the standard control panel by now.

    hopefully this xml just affeccts the stupid f-lock and the keyboard uses the standard UI for remapping the other &quot;special&quot; keys.

  • Fantastic! Now for a hack that physically rearranges the insert/delete/home/end/pgup/pgdn... :-)

  • Sadly, not only microsoft went this way, Logitech decided to follow them and also use the "extended" function keys. Fortunately, my logitech iTouch configuration program allows this nifty setting called "Keep original function" :)

    Maybe you could try installing the logitech itouch drivers, and use them for your microsoft "intelli"type keyboards? Since they're all multimedia keyboards, it might work.

    Gods, I have been annoyed by this for so long, until I got so bothered I had to find a fix. Your post prompted me to explore my own settings, and that made me find the above solution, THANKS!

    @Eddemans: a HACKsaw maybe? ;-)
    Or you could always use the scanmap-trick, and then pry loose the keys and rearange them on the keyboard. (gentle, but persistant, force works on a surprising amount of keyboards)

  • Has anyone figured out how i can get my "print screen" button back as well? i assume that it can be done the same way if i can just figure out what the numbers are that relate to the key. i havn't had any luck so far has anyone else tryed it?

  • wow cheers for the tip, i hate f lock!

  • Thanks!!!

    This seemingly simple hack (if you know how to do it;) fixed this annoying F-lock thing in an instant!

    (Whereas the commands.xml file by Jason Tsang, as well as his "F Lock Key Flip" did NOT work with my MS Office Keyboard!)

  • Thank GOD. I was PS/2 for the longest time and using a different registry fix. However I was forced to switch to USB on my new computer. I had to reboot for the changes to take effect. So you might want to mention this.

  • Seems great!
    But as mentioned before, the only problem is the print screen thing...

    But knowing what file has the info makes the job a lot simpler!

  • How do I change the insert key back to its original function? I still use ctrl-insert and shift-insert for copy and paste (I know, ctrl-c and ctrl-v, but old habits die hard, and why should I change? My computer should adapt to me, not vice versa. Dammit.)
    Anyway, ctrl-insert and shift-insert don't work right when my keyboard is f-locked. Every day it's the same damn thing, the first time I copy and paste I get a printscreen.

  • It didn't work for me - however, I'm just a layman when it comes to computers. I did follow your directions, but when I tried the F5 key, it did not refresh. Guess I just don't have OR KNOW what it takes! Thanks anyway.

  • i have got the "Wireless Desktop Elite Keyboard" and it remebers the f-lock, even though it is connected via usb.

  • The XML hack looks great. I'll give it a try. My problem is how do I get to my BIOS config. My pc looks for F2 to access setup and I'm not getting any reaction to the F2 key.

  • Worked wonderfully and didnt mess up the other buttons. many thanks :D

  • Does the F-lock control the Print screen button? I need to disable it on a number of pcs as a securtiy measure.

  • I hate when I boot up, load a project in Visual Studio, then end up closing a file instead of building!!! Today I finally broke down and was thinking along the lines of the VB Script approach (after finding that you can't map a keystroke through the MS software... WTF?), but this rocks! Ergo, you rock! Thanks Jon.

  • Hoo-ray! Thanks for the tip. Like Brendon above I can now hit F5 to build and run in Visual Studio without having to remember to the pesky f-lock key first! Thanks again for the tip. Think I'll make myself a nice cup of tea to celebrate :-) - might even have a biscuit as well. I can understand MS's thinking with F-Lock but would have made more sense to me if it worked the other way round so maybe F-Lock+F10 kicked of the spell checker rather than say F10 by itself. Oh well...

  • The solution works, though I had to install the intellitype software once again. I almost thought it didn't work.. but it was a simple matter of rebooting.

  • and instead of rebooting for it to work, you could just end the process called "itype.exe" and start a new task named itype (no need to browse to the location of the file)

  • Many thanks for this.

    I got a bit confused as I initially used TextPad to test this but it seems to use the keyboard at a different "level" to most apps and the mappings do nothing. But that is far better than the MS defaults.

    Is anyone else slightly disturbed by the truly terrible XML standards used by MS in this file? I mean, they apparently have one tag defined per language, rather than a more common standard of one tag with an attribute of language (something like '').

  • Thanks a lot! Works like a charm.

  • I blog often and I seriously appreciate your content.

    This article has truly peaked my interest. I am going to take a
    note of your site and keep checking for new details about once a week.
    I opted in for your RSS feed too.

Comments have been disabled for this content.