Keypad gets stuck! Help

if user enters the factory password then it gives the user access to change the factory password to a new one.
I am trying to change the new one, it does work if they give the correct factory pass '123', it asks for a new key but the first and sometimes second digit get stuck with the '3' of the '123'. The press of the factory 3 in the factory key counts in the new key and I don't know how to not have the code do that.
After the user gives correctly the new password the door locks.