Start a Conversation

Unsolved

This post is more than 5 years old

410791

March 18th, 2010 17:00

Keyboard debouncing utility: Solution / workaround for key-bounce issues on certain Dell notebooks

I recently purchased a Dell 1470 notebook and immediately noticed that the keys were "bouncing" (multiple keystrokes registered for a single keypress).  The problem is not isolated to just my laptop or model; as you will find here, it is showing up on others as well.  If you are experiencing this problem, I feel for you. 

The problem was sporadic, but occurred often enough to make my typing look like that of a third-grader (no offense intended to any third-graders out there).  The problem persisted, even after three keyboard change-outs along with an OS wipe/ factory restore and also a motherboard swap-out.  A thorny problem, indeed.  At that point, it was determined that the problem was driver-related.  The keyboard driver is supplied by Microsoft, thus placing me at the complete mercy of the driver development team(s). Searching revealed no resolutions to this issue, no driver updates or patches, neither at Microsoft, nor at Dell, nor on the WorldWideWeb.

Now, being a firmware/software developer myself, I am familiar with keyboard bounce... it exists in all interfaces that have an electro-mechanical switch involved.  The objective is to turn the "chatter" at the switch closure into a clean change of state... "off" to "on", with no chatter at the boundary.   (If you are curious about the topic, you can read about it in detail here.)  Computer keyboards certainly fall into that category.  I realized that the problem existed either in the keyboard driver, the keyboard controller, or the design of the keyboard itself.  I also realized that this issue is not glaringly common enough to garner much priority from developers.  Hence, at least for the forseeable future, this was an "orphan" issue.

Not being a driver developer myself, I took this issue as an excuse to learn AutoHotkey.  I knew about it enough to figure that it could be used to build a keybounce-filtering utility.  Sure enough, I have written an AHK script that does just that: it detects the bounce pattern in the key stream and filters them out on their way to Windows.  You can get it here:

KeybounceFilter.ahk   <-- AutoHotkey script (requires AHK installed)

KeybounceFilter.exe  <-- Compiled script (runs all by itself, no AHK install needed)

AHK forum post

If you are already familiar with AHK and have it installed (it's a great tool BTW), then just download and run the AHK script.  If not, then you might prefer the compiled script (it's the EXE above).  With the EXE, you won't need to install AHK at all.  Just download the EXE into a safe place, then create a shortcut to it, and place that shortcut into your Startup folder (Start > All Programs > Startup).  The script will then run automatically on the next startup.

The filter has a "window time" where it looks for bounces (repeats).  Keybounces usually last in the 10's of milliseconds, being as low as 1 msec for a clean switch closure and as high as 100 msec or more for a particularly dirty one.  I set the default gating window to 40 msec, as a working ballpark figure.  I didn't want to make it too high, because this gating time also sets the upper limit on the auto-repeat rate.  In fact, if you find while running the script that your auto-repeat is choppy or doesn't work at all, you'll want to lower the auto-repeat rate until it works again (don't worry, you'll get it back).  Just go to Control Panel > Keyboard > Repeat Rate and adjust the slider down until it works reliably again.  (note: that has changed: see updates/edits below...)  If you do find that you still get double keys (or triples... I feel for you), then you should increase the gating time.  To do it, right click on the shortcut to the script that you created above, then select "Properties".  Click inside the "Target" box, and at the end of the line, after the "KeybounceFilter.exe", add a space, and then a number for the gate time in milliseconds, then click "Apply".  So for example, if you want the gate time to be  50 msec rather than the default of 40 msec, then the Target Line should look like this:

C:\Users\ \KeybounceFilter.exe 50

You will then need to re-run the script (restart, or just right-click the little "H" icon in the tray, select "Exit", then re-run the shortcut).  Also remember to re-adjust the keyboard repeat rate afterward.  The optimal choice of gating time is therefore striking a balance between the quality of the filtering achieved and the maximum repeat rate that will be available to you.  (note: that has changed: see updates/edits below...)  The filtering probably won't be 100% perfect, but it should go a very long way to helping maintain your sanity (no guarantees, of course).

That's it.  I hope this helps a lot of you out there to keep from pulling all of your hair out!

Edit (2-17-2011): Due to popular request, the script has been updated to now support cAPSLOCK functionality (boo!! hiss!!). The dreaded cAPSLOCK is now enabled by default (no, say it isn't so!!).  Not to be left stuck in this horrible state, cAPSLOCK may still be readily disabled (yay!) by passing a second non-zero numerical argument to the command line. So for example, in the Properties>Target line of the Startup Shortcut, disabling cAPSLOCK with the same 50 msec gate time as in the above example would look like this:

C:\Users\ \KeybounceFilter.exe 50 1

Note that for practical reasons, Shift+cAPSLOCK will also be disabled in this mode, but both Ctrl+cAPSLOCK and Alt+cAPSLOCK will still perform the dreaded cAPSLOCK function (just in case you really need it).  Note also that passing zero (0) for the second argument acts the same as passing no second argument, i.e. it leaves cAPSLOCK still enabled (boo!).  Enjoy and God Bless!

Edit (3-13-2011): Due to popular request (and because it was really bugging me, too), the script has been updated to allow the keyboard auto-repeat feature to work (much more) properly.  Before this change, the gate time for the bounce filter would set an upper limit on the repeat rate, with longer gate times resulting in lower allowable repeat rates.  Now, you can set the auto-repeat rate as high as you like, and it will fly as intended. (In fact, the faster that you set it, the better that it will work!)  The feature works by setting an upper limit on how many bounces are filtered in a row.  In practice, real key bounces should result in fewer than three or four strikes in a row, so the default switchover is set to pass key repeats with more than 3 in a row.  This does add a slight delay to the auto-repeat before it really "kicks in".  You can lower the delay by either increasing the auto-repeat rate (yay!) or lowering the switchover threshold by passing a third numerical argument to the command line.  So for example, setting the Properties>Target line of the Startup Shortcut described above as follows:

C:\Users\ \KeybounceFilter.exe 50 1 2

would set the switchover threshold to 2, while also disabling cAPSLOCK and setting the 50 msec gate time as before.  The danger of lowering the switchover threshold is that really bad bounces (undesired repeats of three or more) would begin to get through.  So use caution, and season to taste.  This update should now remove the one large remaining peeve that existed from the start of this utility.  As always, enjoy, and God Bless!

January 6th, 2011 09:00

LitwDell, no I did not know of that registry setting for FilterKeys. That is really a terrific find. I have read through the whole thread, and based on their findings, that solution should work similarly to what my utility can do. The advantage there is that it is a feature built right in to Windows (XP onward). The downside is that it requires editing of the Registry, which can be dangerous if safety steps are not taken (e.g. backup the Registry, set a System Restore point, etc.).  Also, that method does not eliminate the side-effect of slowing down the auto-repeat rate, it will unfortunately still be limited by the filtering time. It does, however, appear to provide finer control over the settings. The method of choice appears to be given in Post #6 of that thread, with the option in a subsequent post to not bother with turning on FilterKeys at the Control Panel level.

I haven't tried it, so I can't report (yet) on how well either option works. But it does looks like a nice, built-in alternative to the KeyBounceFilter AHK utility, albeit still being a workaround to fixing the real problem at the source: lowering the bounces at the HARDWARE level (hard for Dell to do), or increasing the keybounce-gating time at the DRIVER level (not nearly as hard for Dell to do... but they would need to write and support the new driver).

11 Posts

January 6th, 2011 10:00

LitwDell, no I did not know of that registry setting for FilterKeys. That is really a terrific find. I have read through the whole thread, and based on their findings, that solution should work similarly to what my utility can do. The advantage there is that it is a feature built right in to Windows (XP onward). The downside is that it requires editing of the Registry, which can be dangerous if safety steps are not taken (e.g. backup the Registry, set a System Restore point, etc.).  Also, that method does not eliminate the side-effect of slowing down the auto-repeat rate, it will unfortunately still be limited by the filtering time. It does, however, appear to provide finer control over the settings. The method of choice appears to be given in Post #6 of that thread, with the option in a subsequent post to not bother with turning on FilterKeys at the Control Panel level.

I haven't tried it, so I can't report (yet) on how well either option works. But it does looks like a nice, built-in alternative to the KeyBounceFilter AHK utility, albeit still being a workaround to fixing the real problem at the source: lowering the bounces at the HARDWARE level (hard for Dell to do), or increasing the keybounce-gating time at the DRIVER level (not nearly as hard for Dell to do... but they would need to write and support the new driver).

I've used this registry tweak for the last 12 hours, with NO unintended double hits.  It needs additional tuning because there are side effects - sometimes now it won't show a letter on an intentional double-hit.  I haven't had time to toy with it, but I think it is a significant step in the right direction.  No doubt, the ideal solution will be a fix to the low-level driver.  I'm not holding my breath on that one, but you would think someone would take this problem more seriously - it is unbelievably annoying and makes the machine almost useless.  If I can't get this system to work exactly as I expect it to (just as my previous Dell worked), it is going back.

January 6th, 2011 11:00

Did you just do the regedit / value change / reboot, or did you also check the boxes in the FilterKeys Control Panel?

Are these the values that you used:

My Computer\HKEY_CURRENT_USER\Control Panel\Accessibility\Keyboard Response
    AutoRepeatDelay = 500
    AutoRepeatRate = 50
    BounceTime = 35  (Reduce to a lower number like 25 or 15 if your intentional double strokes are filtered.)

If so then you could indeed try lowering BounceTime. My registry has another field "DelayBeforeAcceptance" (defaults to zero) which I cannot find any documentation on. (Just curious about that one.)

11 Posts

January 6th, 2011 14:00

Did you just do the regedit / value change / reboot, or did you also check the boxes in the FilterKeys Control Panel?

Are these the values that you used:

My Computer\HKEY_CURRENT_USER\Control Panel\Accessibility\Keyboard Response
    AutoRepeatDelay = 500
    AutoRepeatRate = 50
    BounceTime = 35  (Reduce to a lower number like 25 or 15 if your intentional double strokes are filtered.)

If so then you could indeed try lowering BounceTime. My registry has another field "DelayBeforeAcceptance" (defaults to zero) which I cannot find any documentation on. (Just curious about that one.)

Yes, I regedited.  The AutoRepeatDelay and AutoRepeatRate were already set to the numbers above.  I just changed the BounceTime to 35.  I intended on reducing the Bounce, as you prescribe, to a lower number later this evening.

This is too funny.  I couldn't remember how I left the filter keys settings.  So after you posted, I went into the "Ease of Use" center and the "use filter keys" were enabled.  When I clicked on change settings, it actually had BOTH bullets highlighted - BOTH Turn On Bounce Keys and Turn On Repeat Keys.  It's a radio button, so this is supposed to be impossible.  LOL.  It must have something to do with having registry edits.  I canceled out of that screen and left "as is", just as the link instructed to do.

I have the same DelayBeforeAcceptance field.  I will have to research that as well.  I'll let you know what turns up.  Keep me informed if you find something.  Thanks.

1 Message

January 6th, 2011 16:00

Thanks so much for this utility - I have had the keyboard replaced already and the problem still exists on my Dell XPS 1647.

So far so good :emotion-1:

January 7th, 2011 09:00

This is too funny.  I couldn't remember how I left the filter keys settings.  So after you posted, I went into the "Ease of Use" center and the "use filter keys" were enabled.  When I clicked on change settings, it actually had BOTH bullets highlighted - BOTH Turn On Bounce Keys and Turn On Repeat Keys.  It's a radio button, so this is supposed to be impossible.  LOL.  It must have something to do with having registry edits.  I canceled out of that screen and left "as is", just as the link instructed to do.

Oh oh... now you've done it! Two radio buttons enabled at once?  That spells the doom of the world as we know it. You were wise not to change the control panel settings when you saw that ominous sign... you might have been pulled into the Windows Vortex.

I remember when radios actually had mechanical buttons that physically moved the dial to a station that you had preselected (usually by pulling the button out and then pushing it back in). If that mechanism wasn't complicated enough, they also had an interlock that would only let you push one button in at a time. Some radios would have some "play" in the mechanism so if you did push in two buttons at once, the dial would move to somewhere in between the two stations that you selected. So I guess it's not totally impossible to have two radio buttons pushed in at once?   ;)

11 Posts

January 7th, 2011 09:00

[quote user="LitwDell"]

This is too funny.  I couldn't remember how I left the filter keys settings.  So after you posted, I went into the "Ease of Use" center and the "use filter keys" were enabled.  When I clicked on change settings, it actually had BOTH bullets highlighted - BOTH Turn On Bounce Keys and Turn On Repeat Keys.  It's a radio button, so this is supposed to be impossible.  LOL.  It must have something to do with having registry edits.  I canceled out of that screen and left "as is", just as the link instructed to do.

Oh oh... now you've done it! Two radio buttons enabled at once?  That spells the doom of the world as we know it. You were wise not to change the control panel settings when you saw that ominous sign... you might have been pulled into the Windows Vortex.

I remember when radios actually had mechanical buttons that physically moved the dial to a station that you had preselected (usually by pulling the button out and then pushing it back in). If that mechanism wasn't complicated enough, they also had an interlock that would only let you push one button in at a time. Some radios would have some "play" in the mechanism so if you did push in two buttons at once, the dial would move to somewhere in between the two stations that you selected. So I guess it's not totally impossible to have two radio buttons pushed in at once?   ;)

[/quote]

I've reduced the BounceTime down to 30, and now 25, and still no unintentional repeats, and now better response time.  Looking good here.  I finally feel sane.  I haven't tweaked any other settings because I'm trying to carefully, and methodically, test each variable one at a time.

 

 

January 7th, 2011 09:00

Thanks so much for this utility - I have had the keyboard replaced already and the problem still exists on my Dell XPS 1647.

So far so good :emotion-1:

Glad it worked for you too! (And welcome to the club.)

7 Posts

January 31st, 2011 04:00

Hmm.....

I've tried these various registry settings, but must be doing something wrong I think. Despite tweaking them & trying to follow what other people have suggested, It gives a repeat rate when double typing a letter that seems too slow to be usable at the speed I type - I have to wait about a second before I can hit the key again if I want to type the same character again.

Autorepeat seems to stop working completely -  I can hold the key down & nothing happens.

 

January 31st, 2011 08:00

mat, it seems to be acting (long delays, etc.) like it does when just using the Accessibility GUI. Did you try turning the BounceKeys and FilterKeys off in the GUI and then making the recommended registry value changes? Also, did you try restarting after editing the Registry?  (These are just guesses, since I have not actually tried this method... I'm still using my AHK utility. Perhaps someone who has had success could chime in with some more help there.) Of course, if you can't get it working that way, you could always try using the AHK utility in the top post of this thread.

February 8th, 2011 14:00

Dear Kingdomseeker,

I just bought a new Sony Vaio running Windows 7. It has the double character problem. Sony are telling me they'd like to take the machine back for repair; but I just KNOW that they won't find the problem, as it's intermittent (every few sentences)...and I need my laptop for my work.

Nothing Sony has suggested to date has worked...

Hence I was DELIGHTED with your script.........I've downloaded the .exe version. Forgive my ignorance, but I am NOT at all a computer expert....For me, these machines are just tools. I know nothing about 'autohotkeys'!!  BUT I REALLY would like to restore the CAPS LOCK function....Is there a way for someone as ignorant as me to restore this function from the .exe version of the programme, without getting into a terrible mess??!! It really would help....

Basically, I'd LOVE the computer simply to function as it was meant to function. Your script almost gets there...and using it is INFINITELY better than trying to live with the double characters!! Just it would be nce to get that Caps Lock key back (even though you may regad t with utmost contempt!!)

(And what a PAIN that Sony surely know about this problem but couldn't insert a fix....)

Grateful in Barcelona...

February 9th, 2011 13:00

...I REALLY would like to restore the CAPS LOCK function....Is there a way for someone as ignorant as me to restore this function from the .exe version of the programme, without getting into a terrible mess??!! It really would help....

Basically, I'd LOVE the computer simply to function as it was meant to function. Your script almost gets there...and using it is INFINITELY better than trying to live with the double characters!! Just it would be nce to get that Caps Lock key back (even though you may regad t with utmost contempt!!)

Hello al,

Well I checked on the download site, and from what I can tell by examining the .AHK file there, the .EXE should already have the cAPSLOCK remapping removed (the line containing the remap is commented out, so the cAPSLOCK should funtion normally).  I'm not sure what would make it continue to remap it like that.  If others have similar complaints I could go back and try re-compiling, but testing it would require changing some things on my machine too... so it would have to happen when I get some time to do it.  In the meantime, if you are daring, you could try the regedit approach mentioned a few posts up. Here it is, spelled out for the interested reader:

Note that you should not run the AHK script if you use this method, nor should you have to.  It basically does what the AHK script does, except it uses functionality built in to Windows, and may even work better because of it.  To be cautious, first save a backup of your registry, or if you prefer, just create a Restore Point. Then,

Start > type "regedit", open the Registry Editor, then go down the key heirarchy to find:

Computer\HKEY_CURRENT_USER\Control Panel\Accessibility\Keyboard Response

then modify the following fields to have these values:
    AutoRepeatDelay = 500
    AutoRepeatRate = 50
    BounceTime = 35

Then exit regedit and restart the PC.  The values can be later re-edited as needed to get the desired keyboard response. (For example, reduce BounceTime to a lower number like 25 or 15 if your intentional double strokes are filtered.) Note that I have not had an opportunity to experiment with this method myself; I am just forwarding information from others who have successfully tried it, some of whom have already posted in this thread. I wish you well in your efforts!

February 16th, 2011 12:00

Hi KingdomSeeker,

 

Strange...when I use your utility and press the Caps Lock key I get a capital letter on the first key I strike...and then it reverts to lower case (with the Caps Lock still locked).....weird.....Maybe it's something to do with the filter keys settings???

 

Again, may I express my appreciation for the light you have shed on this intensely irritating problem.....I'll be trying the regedit route in a week or so....presently I'm travelling and I don't dare touch the registry until I'm back at base and have access to a spare laptop - in case things go badly wrong!!

 

All the best, Barcelonaal

February 16th, 2011 22:00

Due to popular request, the debouncing script has been updated to support the (dreaded) cAPSLOCK function. For details, please refer to the top post of this thread (see edits near the bottom of the post).

February 17th, 2011 09:00

That's great to see Al...  mostly, it just bothered me that it didn't work with that key, and I was curious as to why. When I figured it out, I went ahead and added the extra command-line argument for controlling it, and then tested and deployed it.

Wow, I could probably excuse you for liking the cAPSLOCK if you were to host me for a meal in London or Barcelona (or southern France)!  I'll let you know if I'm ever going that way!

No Events found!

Top