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

Laptop

Laptop
Laptop computer Forums (Audio, General Hardware, Video)

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

This question has suggested answer(s)

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\<path to the script>\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\<path to the script>\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\<path to the script>\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!

All Replies
  • I now have your exe on my Inspiron 1521 which has given me double rr since new.  Talking to Dell gave no solutions.  Your exe seems to have solved the problem - hurray!!! Thank you!!!  One small thing; the backspace is now slow.  Can that key be rmoved from a key list?

    Thanks again!!!

  • Hey, I'm delighted to know that this little utility has helped someone besides just myself!  (I was starting to wonder if everybody's double-keystrikes had somehow magically all disappeared!)

    Before firing off suggestions, I should ask... by "slow", do you mean that the auto-repeat on the Backspace is slow?  I ask this because that's the usual way people use the Backspace key, me included.  (For the uninitiated reader, the "auto-repeat" is what happens when you hold the key down.  It fires-off the key like a machine gun, saving you from having to strike the key over and over.)  If this is the case, then please read through my top post where I talk about adjusting the auto-repeat rate down (around the third paragraph from the bottom).  This is important, because auto-repeat affects all keys, not just Backspace.  (Think how often you auto-repeat the Space bar, or dashes, or the cursor/arrow keys!)

    Otherwise, you have a couple of options.  You could shorten the gating time to less than 40 by modifying the shortcut like I describe in the last two paragraphs of my top post.  Finally, you can modify the script (AHK) file to remove the Backspace (or other special keys).  If you really need it, I can tell you which lines to remove.  But you will want to install AHK so that you can run the modified script.  (I hope you understand... I'd rather not get into the business of creating custom scripts... that could turn into a full-time activity!!)

    Hope that helps!

  • Haha, thanks for the kudos.  The real fix for this problem would be at the driver/controller level, to tweak the debounce routine and nix the bounces at the source. Doing that would side-step the side effect of having a hard ceiling on the auto-repeat rate. Fortunately, for me at least, the bounces are all sub-50 msec so that the auto-repeat rate ceiling is not too low for me. (Yup, I had to up my gate time to 50 to squelch some rougue bouncers).

    Typing in Caps... Did you mean the cAPSLOCK key? If so, then my apologies, I have that key permanently remapped to LeftShift!  I have no use for that key (actually, I have nothing but utter disdain for that key), and hence I did not test it.  If you absolutely must have it, there probably is a way to make it work by editing the script.  FWIW, I DO GET ALL CAPS WITH THE SCRIPT RUNNING ON MY INSPIRON 1470 BY HOLDING DOWN EITHER LSHIFT OR RSHIFT (OR OF COURSE, CAPSLOCK) AS I TYPE.  It works for me in Notepad, Windows Explorer, OpenOffice, and web browsers like this forum page (obviously).

    On the subject of cAPSLOCK, for any of you out there are interested in relegating that vile vestigial hang-over from the typewriter age to be a nice, kind LShift key, you can do it by un-commenting line 24 of the current version of the script KeybounceFilter.ahk:

    Capslock::LShift 

    i.e. remove the semicolon (;) at the start of the line.  That's the AutoHotkey language for creating a hotkey-map.  You can also use the Keymaps that are built into windows, but since you're running the script anyway, there's not really much overhead involved. And this way, you don't need to edit the Registry.

  • Sorry to see you have had such a rough time with this, aleki.  I must say that this experience has tried my patience as well.  Dell did what they could, but in the end, the problem was not fixed.  So, I am happy to provide this option to those who are stuck waiting for when (or if) the driver or controller can be corrected.

    I am mystified why your Shift function is not working with this script.  However, now that I am clearer on what it is, let me walk you through the process of modifying the AHK script.  First, download the AHK script (not the EXE).  Open it in Notepad (or if you are a developer, your favorite code editor).  Now go to line 47, which looks like this:

    Hotkey, +%k_char%, k_KeyPress

    Now comment this line out by adding a semicolon.  It should then look like this:

    ; Hotkey, +%k_char%, k_KeyPress

    This is the line that captures all shifted keys for filtering.  By "removing" this line from the script, it will no longer filter shifted keys.  Let's see if this at least brings them back for you, even though they will not be filtered.  Save the modified script, say, as something like  "KeybounceFilter_NoShift.AHK".  Then go to the Download page of the AutoHotkey site and download and install the latest build of the AHK Installer.  Once installed (and maybe after a Restart), you will be able to run the script that you just modified directly in its AHK form (just double-click the script).  Also, make sure the old version of the script isn't still running when you are running the new one.  If it works, just make a shortcut to the new one like you would have done for the old one, in the Startup folder.

  • I've tried installing your script & it seems to be doing a great job of eliminating the problem of duplicate letters appearing. Since installing AHK though, various other common key combinations seem to have stopped working, such as alt+tab & windowskey+e (to open explorer). Can you confirm whether this is a side effect of the script, or am I doing something wrong?

    Many thanks for your efforts to solve this problem.

  • Hi mat,

    Glad to be of help.  It's not something that you are doing wrong.  The script was capturing those keys and filtering them, but with the side-effect of Windows hotkey functionality being lost.  (I probably got over-zealous with the filtering of these special keys.) 

    I have updated the script so that it no longer captures Alt and Win.  This should be a fairly transparent change... the only forseeable side effect would be that these two keys could possibly double-strike, but this is probably innocuous and a more rare event, since the users' fingering is usually more "careful" with these keys.

    Please download the script and/or exe file again (same link above) and the normal funcitonality of the Alt and Win keys should now be restored.  Blessings...

  • Great.

    Thanks for such a quick response.

    I'm trying the updated version of the script now & it seems to be working ok so far. Will let you know if I come across any other issues.

  • Script updated again today. Corrected side-effect where "+" and "^" were not coming through the filter.

  • Script has been updated to correct improper trapping of the "}" key.

  • Thanks for kkeeping this utility updated kingdoseeker. I am still having issues even in my brand new replacement.

  • No problem aleki... It's good to know that the utility is helping.

    Actually, another Dell user pointed out the bug to me. I fixed it right away because I need that key too! (I was surprised that I hadn't noticed it before.) So, I'm in there with all of you, at least until Dell can devote a little time to tweaking the debounce portion of their keyboard driver. As much as I like helping out, it would be better if their driver development team could fix the problem at the source.

  • Hi,

    thanks for providing a solution to this issue. While searching for more information, I came across a Microsoft tutorial dealing with duplicate characters in the Ease of Access Center: http://www.microsoft.com/enable/training/windowsvista/bouncekeys.aspx

    On my e6410, this seemed to reduce the problem pretty similarly to the KeybounceFilter, although from time to time the problem still occurs.

    Oliver.

  • Hi Oliver,

    I also tried that FilterKeys approach, but I was disappointed that the minimum filtering time offered by Windows was 0.5 seconds (500 milliseconds).  That was way too slow for my typing... I couldn't wait that long to type words with double letters, like "school", which would come out as "schol". It became as much a problem as the original problem. My utility should allow you to set the filtering time down to well below 50 milliseconds, which will still allow for pretty decent typing speed, as long as your keyboard bounce is not too severe.

    On that topic... I have noticed recently that the bouncing on my Dell Inspiron 1470 keyboard has gotten worse. I had to up the filtering time to 70 msec to keep the output clean. Oh well, at least I can still type with the thing!

  •  

    I just received my system two weeks ago, and I have the exact same problem.  I've read threads going back to early 2009 with reports of this problem.  I'm running in circles with Dell support.  I may try the scripts provided above (thanks to the author for posting it), but as mentioned - this really doesn't feel like a permanent fix.  This keyboard double-hit is driving me crazy.

     

  • KingdomSeeker288

    Hi Oliver,

    I also tried that FilterKeys approach, but I was disappointed that the minimum filtering time offered by Windows was 0.5 seconds (500 milliseconds).  That was way too slow for my typing... I couldn't wait that long to type words with double letters, like "school", which would come out as "schol". It became as much a problem as the original problem. My utility should allow you to set the filtering time down to well below 50 milliseconds, which will still allow for pretty decent typing speed, as long as your keyboard bounce is not too severe.

    On that topic... I have noticed recently that the bouncing on my Dell Inspiron 1470 keyboard has gotten worse. I had to up the filtering time to 70 msec to keep the output clean. Oh well, at least I can still type with the thing!

    KingdomSeeker288 - Have you seen this proposed solution to double-hits?  (found this on a 2008 thread).  I thought you might have some feedback on this approach - did you know this registry setting existed (was modifiable)?

    http://forum.eeeuser.com/viewtopic.php?pid=364796#p364796