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

I'll give it a hit...good job.

Tuesday, November 29, 2005 4:54 AM by jayson knight

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

I can't wait to try this. Those dumbass special function keys are horrible. I don't mind them being there, but I cannot believe how arrogant MS is to make them enabled by default.

Thank you Jon!

Tuesday, November 29, 2005 7:28 AM by Ron Shelton

# 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 MS Natural Ergonomic 4000* actually restores the last state of F-Lock (eg, OFF) when unplugged and re-plugged via USB. I've personally tested this and it's true.

http://www.codinghorror.com/blog/archives/000400.html

PS/2? C'mon. That's so 1996.

* AKA THE BEST FREAKIN' KEYBOARD EVER. EVER!

Tuesday, November 29, 2005 4:03 PM by Jeff Atwood

# 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 03, 2006 4:32 PM by Jules Kerssemakers

# Link-O-Rama

Another month. Another collection of links... Sports/Packers/Racing Turiaf will play for Yakama Sun Kings

Thursday, September 14, 2006 2:23 AM by Rick.Stavanja.com

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

Wow, what a relief. I just plugged in an old Dell keyboard that doesn't have an F-lock key. However, windows was treating the keyboard as if the keys were F-locked. After two days of searching, I came across this solution. It worked great. Many thanks!

Wednesday, February 07, 2007 4:41 PM by Nick

# 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 02, 2007 8:48 AM by asdfasdf

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

Does anyone know what to do about my intelitouch mouse and track pad on my Toshiba laptop running MS Vista (crap) software?  I seem to have fallen asleep face first on my keyboard (and who hasn't, huh...huh?) and pressed some combination of keys that have turned of my tracker and mouse buttons and i get no response at all from them, luckily I remember all the pre-mouse days commands and can manage, but I sure have gotten used to the speed of the mouse especially  cuz of how rusty I got not using the commands for so long...  Thank you so ery much!!

Friday, January 18, 2008 11:39 PM by Jemi

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

how to impleament this code in ASP.NET working on C#....

please give me answer at my email id:

nitinvaghela.333.ce@gmail.com         please

Thursday, January 31, 2008 3:00 AM by Nitin

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

Thank you so much for this... You are a lifesaver sir

Wednesday, February 20, 2008 8:22 AM by Travis

# 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

# disable f lock

Pingback from  disable f lock

Friday, April 25, 2008 4:00 AM by disable f lock

# 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 09, 2008 8:08 AM by DaleB

# keyboard function keys

Pingback from  keyboard function keys

Thursday, May 15, 2008 7:08 AM by keyboard function keys

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

I love you. This has been pissing me off for ages!

Friday, June 20, 2008 1:02 AM by Masty

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

This is the it. No more crap from the F-Lock.

I'm saved.

Sunday, July 27, 2008 11:25 AM by Heinz

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

Some older Logitech keyboards do not allow you to easily disable this.  But it's possible with itouch.

1.  Open up itouch software

2.  Go to F-Lock tab

3.  double click on f1

4.  Set to Key combo

5.  click on first box and call it F1

6.  Click in second box, and hit F1.

7.  Hit okay.

8.  Repeat steps 3 through 7.

Annoying as hell.

Friday, August 15, 2008 9:56 PM by Gonzo Granzeau

# 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

# Enable Media Buttons when Locked | keyongtech

Pingback from  Enable Media Buttons when Locked | keyongtech

Thursday, January 22, 2009 3:06 AM by Enable Media Buttons when Locked | keyongtech

# Link-O-Rama (December 2005)

Another month. Another collection of links... Sports/Packers/Racing Turiaf will play for Yakama Sun Kings

Wednesday, March 04, 2009 1:38 AM by Rick.Stavanja.com

Leave a Comment

(required) 
(required) 
(optional)
(required)