3x4 matrix keypad repeat button presses

Hello, I have 3x4 matrix keypad (the 12 button one from Sparkfun) hooked up to an arduino Duemilanove with the matrix keypad library. I am getting repeat button presses at seemingly random intervals and I cannot figure out why. It does not appear to be caused by the way the button is pressed. I tried holding a button down for a long period of time, pressing quickly, slowly, and releasing half-way and pushing down again. None of those produced the problem consistently, so I assume it has to be an error in my code somewhere.

The code is too long to post here, so I uploaded it to pastebin:

(It is for a Airsoft/Paintball bomb prop like the one in the Counter-Strike videogame)

When a key is pressed, the loop runs correctly, verifies that the key pressed matches the stored code, and then it loops through again without waiting for a new key press for some reason. I thought it might be junk data stored in memory, so I changed the "char key;" line from the example to char "key = '\0';", and I still have the same problem.

Thanks in advance for the potential help, sorry my code is so ugly.

Did you use the example code provided with the library to test the keypad? The example code works for me so it is fine.

I used the keypad library also, worked great for me, and I expanded the size to 4x4.

Yes, I used the example code from the library. Created a do loop that keeps looping until a key is pressed. I just noticed something odd though. I have tried 3 separate matrix keypads from Sparkfun, all of them have this problem. I just went out and bought a Valleman 4x4 matrix keypad from a local store, and it doesn't have this problem. So maybe its not my code? I'd like to be able to use the sparkfun keypads because they are cheaper, and I don't need the 4th column.

Heres a better description of what is happening. If I type in a series of digits, like "8507840", the arduino will read something like "885078440". The digits that are doubled are not always the same. I'm going to upload just the example code to it and see if I still get the error.

EDIT: Just tried the code from the library here: Arduino Playground - Keypad Library Had the same issue.

Maybe the button bounces? Anyways, you might want test your keypad manually since the code seems to be fine.