The thing you are experiencing is due to so called bouncing of the key, which is basically very rapid change in the signal level when a key is pressed and released. Since these changes are all recorded, inputs get added in your case.
You will need to include a key debounce method such as the one explained in this link. One could debounce by increasing the sampling interval, but more elegant way is to have a state machine which avoids re-registering of input, once it is registered. This will achieve the desired effect of the key being held pressed and still only one input being registered.