Start a Conversation

Unsolved

This post is more than 5 years old

410744

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!

5 Posts

June 28th, 2011 01:00

This topic is becoming really popular!!!

As a user of one of these faulty dell laptops I'm suffering the same keyboard related problems.

I tried your fantastic AutoHotKeys script and it worked great, then the registry mod, and it worked too.

But both of them have the same limitation: they only work AFTER windows logon!

Obviously, there is no problem with autologon enabled, or if you did not set a windows password, but if you did... it is hell.

Doe to the faulty keyboard I had to type my windows password again, and again, and again, counting the characters to be sure it was right.

So I made another registry mod to avoid that logon problem

Go to HKEY_USERS\.DEFAULT\Control Panel\Keyboard and modify:

KeyboardDelay 35

KeyboardSpeed 10

Then go to  HKEY_USERS\.DEFAULT\Control Panel\Accessibility\Keyboard Response

AutoRepeatDelay  500

AutoRepeatRate  50

BounceTime  25

DelayBeforeAcceptance 0

Flags 31

Restart and voilà, no more repeating keys at windows logon!!!

How does it work?

The HKEY_USERS\.DEFAULT (look carefully, there is a point in front of DEFAULT) is the place that holds the profile for the Local System account. And Local System is where winlogon and logonui run, that's BEFORE any user logs in.

July 18th, 2011 15:00

Thanks for the clever solution, Esteban!  A question: By applying it to HKEY_USERS\.DEFAULT ,  does it then apply to all users, or would it also need to be added for HKEY_CURRENT_USER as given earlier?

5 Posts

July 21st, 2011 13:00

Sorry for the delayed response.

As far as I know, the HKEY_USERS\.DEFAULT key refers to everything that is loaded BEFORE you log into a specific user account, even if that account is the default user. But those settings are not "inheritable", so you must specify them for every user account to make the thing work.

On the other hand, this keyboard workaround is just a workaround (for windows users only), it does not fix the real problem: bad quality hardware. And it worsens with time (I'm experiencing it right now).

I found a solution at the physical level, but it is not for the faint-hearted... believe me:

The key of the problem is in the chemical composition of the conductive traces over the membrane used in this kind of keyboard. Take a look at "keyboard technology" on Wikipedia.

The conductive traces of our keyboards (and the areas where they make contact) seems to be composed of a bad mixture of metals that exhibit a particular fast tendency to tarnish (a form of corrosion). That low conductivity tarnish is the REAL cause of all our troubles.

So you can restore the initial condition of the keyboard removing that tarnish by means of an electrochemical reaction. But it also means that you must remove the faulty keyboard, soak it in a special solution (yes... you must submerge the whole keyboard in a chemical solution!!!), rinse it with lots of distilled water and then let it dry in the presence of a dissecant.

If somebody really wants to try it (a very desperate one) I can write here the whole procedure in detail.

July 23rd, 2011 07:00

Thanks, Esteban for the explanation of the registry keys.

I believe that you are 100% spot-on about the key-contact issue. It makes perfect sense, too, from the perspective of the keyboard drivers. The drivers are designed for "typical" key-contact noise bursts, but these keyboards are evidently producing noise quite longer than those drivers were designed for. Corrosion of the metal could certainly increase contact noise.

I would be intereste in knowing more about what you did.  Even with the utility running, I still get the (very) occasional double-strike. If it ever were to get worse, I might be inclined to more "desperate" measures! Also, in the course of all my repairs, I was left with an extra keyboard part from one of the parts swap-outs. It might be interesting to experiment cleaning methods with.

5 Posts

July 24th, 2011 17:00

Good, if you have the opportunity to do some experiments, here we go.

By the way,  sorry for my English, I just speak Spanish.

As a chemist, the first thing that raised my suspicions was the darkened conductive tracks near the connectors end (hmmm... that's so typical of silver or siver based alloys...).

Now let's remove that tarnish (silver sulfide).

First thing, get an appropiate plastic recipient to keep the keyboard part fully submerged in the chemical solution (I got one from my mother's kitchen, a shallow rectangular recipient she used for storing pies in the refrigerator).

Now the chemicals: go to your chemical supplier and get 5 litres of distilled water, 1 gram of a non-ionic detergent (ask the attendant), 100 grams of Ammonium Thiosulfate solution (50 gr of Sodium Thiosulfate also works, but  you must add some Ammonium Chloride to the treating solution),  and some cheap dissecant (fused Calcium Chloride, silicagel, whatever). Take into account that these chemicals are often used in classical photographic development, so you can also find them at photo labs suppliers. If there is no way you can get some Sodium or Ammonium Thiosulfate (photographers calls it "hypo") you can try any black-and-white photographic fixing solution.

The formula: dissolve the 100 gr of Ammonium Thiosulfate solution in 1 litre of distilled water at room temperature. Once the Thiosulfate gets dissolved,  add 1 gram of non-ionic detergent. If you got Sodium Thiosulfate, use 50 gr but also add 10 grams of Ammonium Chloride to the solution.

The procedure: remove your keyboard from the laptop (get the disassembly instructions for your model), brush it with a dry brush to remove any dust or dirt, put it in the plastic recipient and pour the cleaning solution until it gets completely submerged. While you dry your tears, slowly move the recipient to stir the solution around the keyboard, then go to bed or watch some tv to forget the horrible act you just made.

The next day, return to the crime scene, take the keyboard out of the cleaning solution and use ALL the remainig distilled water you have to rinse it. This part is very important, if you don't remove any traces of the cleaning solution you are putting your laptop at a serious risk. So rinse the piece by drowning it many times in clean distilled water, replacing that water  from time to time, and letting the piece stay under water a couple of hours.

Once you are really sure you washed every bit of cleaning solution, dry it with some paper, put your keyboard in a dry recipient (it can be the same used before if it has a closure) with the dissecant (obviously, you must accomodate the dissecant to not make direct contact with the keyboard), and close the recipient (the most hermetically you can).

Now let the thing dry a couple of days... then take it out the recipient, put it in your laptop and enjoy!!!

If you want to know the details of the electrochemical reaction, I will explain later.

July 25th, 2011 07:00

Wow, Esteban, that is remarkable... definitely not for the faint-of-heart! But it's good to know that such a chemical "solution" exists (please pardon the terrible pun). And by the way, your English is impeccable. Buen hecho, y buen provecho!

5 Posts

July 25th, 2011 11:00

Gracias amigo!

Now is time to explain the chemistry behind the procedure.

If the conductive tracks of our keyboards are composed of silver (or some silver alloy) then the dark tarnish they exhibit must be Silver Sulfide. The problem with that sulfide is its great stability that makes it resist the attack of every known solvent (en.wikipedia.org/.../Silver_sulfide).

But our keyboards have exactly what is needed to resolve the problem: a lot of aluminium.

When a silver compound gets in contact with metallic aluminium in a conductive solution (also known as electrolyte) the silver in it gets reduced to metallic silver while the aluminium gets oxidized to inert alumina. As you can guess, the amount of aluminium that gets oxidized is so small that is almost invisible compared with the total amount present in the keyboard.

But why we must use that weird thiosulfate solution?

Well, for the whole thing to work you must use something that dissolves at least a very tiny amount of silver sulfide. And that's exactly what thiosulfate does.

Once all the silver sulfide reverts to metallic silver you must eliminate every trace of electrolyte and then completely dry the keyboard to put it again to work.

And that's all!

5 Posts

July 25th, 2011 23:00

OMG, I just realized that I made the cleaning solution formula unnecessarily complicated. That's the problem with chemists!

Let's keep it simple. There are two options:

You can go to you local photo lab and ask the attendant for a non-hardening photographic fixing solution (black-and-white processing the better). Tell him that you are going to use it for a special purpose, so you need a very "mild" non-hardening fixing solution (not very acidic or alkaline). If the man offers you a concentrate, then ask him how to dilute it to get a fixing solution that is half of the concentration of a regular processing bath (and remember you need only 1 litre). Once you get it, to be completely sure the thing is harmless to your keyboard, you can make a little test: drown a piece of aluminium foil into the solution and let it stay that way for a couple of hours. If everything is ok the aluminium foil must remain absolutely unchanged.

If I made my numbers well, you are going to spend less than 6 bucks.

The other option is buying some "Ilford Rapid Fixer" at some online photographic service. As far as I know, the minimum amount you can order is 500 mL (6 to 8 USD). For our purpose follow the instructions printed in the bottle but using half the amount indicated in order to make 1 litre of processing solution. You can do the same aluminium foil test to verify it is harmless to your keyboard.

Now you have the cleaning solution, the rest of the procedure remains the same.

July 26th, 2011 11:00

Thanks for the simplified explanation. It looks like a fascinating journey, if me or anyone reading this wants to take it.

If you do, but you're scared yo umay be left with a laptop with a melted keyboard, you can find backups/replacements here:

www.directron.com/rxj8t.html

This is for Inspiron 1470 (mine) but you should be able to find ones for others either at that outlet or others (just google "replacement keyboard XXX" with your brand/model for the XXX.  Cheers and God bless!

7 Posts

October 6th, 2011 20:00

@KINGDOMSEEKER288 - Man oh man! You are my HERO! You just made my brand new Dell Vostro 3750 my dream machine, as I had hoped it would be but was so very disappointed to find out it had the keyboard problem everyone was experiencing here. Dell owes you BIG TIME, and I think you should have a way for folks to make donations to you to show their appreciation. If you are ever in Zihuatanejo, Mexico I would be honored to treat you to at least a hearty meal and the libations of your choice! ¡SALUDOS!

November 11th, 2011 07:00

@ZihuaRob - I truly appreciate your sentiments. Re: donations, It is payment enough for me to know that people are being helped by the solutions in this thread, and especially that they are not having to throw away their expensive machines, which except for this silly issue, are actually great machines.

For you, or also for anyone else who feels a need to express thanks in a material way, may I please suggest a charity: Servias Ministries. Their mission is to help widows, orphans, and the poor and disadvantaged. They are very honest and fruitful in their work.

Thank you Rob for your very gracious offer... I have never been in Zihuatanejo, but my wife and I have dreamed of visiting someday. I will let you know if we are ever in your area!   ¡MUCHAS GRACIAS!

July 12th, 2012 00:00

Do you have any thoughts on why the regedit route achieved nothing? yes I do, I was having the same issue at first, with my BounceTime registry setting doing absolutely nothing, but I finally got it working, and with my choice of AutoRepeatRate also working. (Windows 7 64-bit).

The Flags registry key (found in this section:HKEY_CURRENT_USER\Control Panel\Accessibility\Keyboard Response) is a numerical configuration value relating to these features being on/off, beeps sounding, and so on. You probably don't have FilterKeys on, which is necessary for these changes to do anything.  The flags appear to have the following meanings (this assumes your options are the same as mine, and you didn't change anything else from default values, like de-selecting "show FilterKeys in taskbar"; if you do that, that's fine, but your actual Flags numbers will be slightly different):

126 - FilterKeys off

123 - FilterKeys on, but with the annoying beep (these are bit masks, in binary this is 1111011)

59 - FilterKeys on, no beep (in binary, 0111011 -  the "64" slot, the left-most bit in this case, has changed to 'off')

to fix:

  1. go through the Control Panel to the Ease of Access Center and turn on FilterKeys. If necessary, make sure only one radio option between BounceKeys and RepeatKeys is selected, and then proceed to pick a value for BounceKeys.  Select something dumb like 2.0 seconds, and verify in the text box that it's really on. De-select the "play annoying beep when I press a key" checkbox while you're at it.
  2. Open regedit.  I found the appropriately big number for BounceTime, 2000 - change that to 35 or 40 (milliseconds). Note that AutoRepeatDelay and AutoRepeatRate were now set to zero (meaning disabled, since these features are, for some reason, supposed to mutually exclusive, hence the radio buttons) - I set these to 500 and 50 respectively - these options do not appear to effect the doubled-keys situation at all.  The Flags key should already say 59.
  3. You're done, reboot.  If you go back into the Ease of Access/keyboard dialog to look at the settings, you'll see that by changing the autorepeat rate and delay options, BOTH radio buttons are selected - this does not, apparently, cause a singularity.  Click Cancel, not OK or Apply!

a summary of the registry settings that tamed my doubled-spaces:

  • autorepeatdelay:500
  • autorepeatrate:50
  • bouncetime:40
  • delaybeforeacceptance:0
  • flags:59

good luck!

1 Message

June 9th, 2014 07:00

The links are broken.  Is it still possible to get the latest version of this script?

- Nevermind, I went with the registry changes.  Appears to be much better so far.

2 Posts

August 8th, 2016 08:00

I hope  to resurrect this thread.  The links for the AHK  script are dead, and I have also triedd many different times to solve this problem using the registry editor as prescribed in this thread, which seem to have no effect at all.

I have tried a debounce time of everything between 10 to 100, and also disabled/enabled BounceKeys and Repeat Keys in Accessibility options.  

I am using a Toshiba S50-D laptop running Windows 8.1

Can some send me the script?

7 Posts

August 9th, 2016 19:00

Here you go. I think it can be downloaded from this free file-sharing service. (Hope I'm not breaking any Dell Forum rules.)

www.filedropper.com/keybouncefilter

No Events found!

Top