[fix] Killing the F-Lock on MS Keyboards (even under USB) - Jon Galloway

[fix] Killing the F-Lock on MS Keyboards (even under USB)

Summary

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" ?>
<DPGCmd>
    <Copyright>
        
Copyright (c) 1983-2005 Microsoft Corporation. All rights reserved.
    
</Copyright>
    <
Version>5.30.606.0</Version>
    <CHS 
/>
    <CHT 
/>
    <ENG 
/>
    <FRA 
/>
    <DEU 
/>
    <ITA 
/>
    <JPN 
/>
    <KOR 
/>
    <PTB 
/>
    <PTI 
/>
    <ESP 
/>
    <ALL>
        <Application 
UniqueName="StandardSupport">
            <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" />
        <
/Application>
    <
/ALL>
<
/DPGCmd>

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.

Published Tuesday, November 29, 2005 6:26 AM by Jon Galloway
Filed under: ,

Comments

# re: [fix] Killing the F-Lock on MS Keyboards (even under USB)

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 "My Music" 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!

Tuesday, November 29, 2005 5:05 AM by Collin Yeadon

# re: [fix] Killing the F-Lock on MS Keyboards (even under USB)

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

Tuesday, November 29, 2005 7:23 AM by Paul

# re: [fix] Killing the F-Lock on MS Keyboards (even under USB)

Great Hacking !

Finaly a solution !!!

Thanks.

Tuesday, November 29, 2005 3:58 PM by Ohad Israeli

# re: [fix] Killing the F-Lock on MS Keyboards (even under USB)

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 "special" keys.

Tuesday, November 29, 2005 6:03 PM by olli

# re: [fix] Killing the F-Lock on MS Keyboards (even under USB)

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

Friday, August 25, 2006 3:32 AM by Eddemans

# re: [fix] Killing the F-Lock on MS Keyboards (even under USB)

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)

Sunday, September 3, 2006 4:32 PM by Jules Kerssemakers

# re: [fix] Killing the F-Lock on MS Keyboards (even under USB)

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?

Saturday, September 23, 2006 8:51 AM by Andrew

# re: [fix] Killing the F-Lock on MS Keyboards (even under USB)

wow cheers for the tip, i hate f lock!

Friday, October 20, 2006 6:50 AM by anthony mckale

# re: [fix] Killing the F-Lock on MS Keyboards (even under USB)

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

Friday, December 29, 2006 3:33 PM by David.P

# re: [fix] Killing the F-Lock on MS Keyboards (even under USB)

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.

Thursday, February 22, 2007 7:44 PM by Mark O'Neal

# re: [fix] Killing the F-Lock on MS Keyboards (even under USB)

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!

Tuesday, March 13, 2007 9:59 PM by Gustavo

# re: [fix] Killing the F-Lock on MS Keyboards (even under USB)

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.  

Monday, April 23, 2007 5:57 AM by Strat Douglas

# re: [fix] Killing the F-Lock on MS Keyboards (even under USB)

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.

Saturday, July 21, 2007 3:10 PM by Patti Hall

# re: [fix] Killing the F-Lock on MS Keyboards (even under USB)

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

Sunday, September 2, 2007 8:48 AM by asdfasdf

# re: [fix] Killing the F-Lock on MS Keyboards (even under 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.

Friday, March 28, 2008 11:03 AM by Ed Mitchell

# re: [fix] Killing the F-Lock on MS Keyboards (even under USB)

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

Saturday, April 19, 2008 12:06 PM by Null-Entity

# re: [fix] Killing the F-Lock on MS Keyboards (even under USB)

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

Friday, May 9, 2008 8:08 AM by DaleB

# re: [fix] Killing the F-Lock on MS Keyboards (even under USB)

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.

Monday, June 23, 2008 9:43 AM by Brendon

# re: [fix] Killing the F-Lock on MS Keyboards (even under USB)

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

Thursday, August 14, 2008 4:00 AM by MattB

# re: [fix] Killing the F-Lock on MS Keyboards (even under USB)

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.

Friday, October 31, 2008 2:50 AM by ArchZeratul

# re: [fix] Killing the F-Lock on MS Keyboards (even under USB)

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)

Saturday, August 8, 2009 12:31 PM by Avi

# re: [fix] Killing the F-Lock on MS Keyboards (even under USB)

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 '<KB_SETTINGS LANGUAGE="ENG">').

Sunday, December 27, 2009 1:50 PM by Colin Main

# re: [fix] Killing the F-Lock on MS Keyboards (even under USB)

Thanks a lot! Works like a charm.

Monday, June 13, 2011 5:12 AM by Dekel Tal

# re: [fix] Killing the F-Lock on MS Keyboards (even under USB)

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.

Friday, October 26, 2012 6:01 AM by Chow