The only way I can see of bettering the code (maybe) without making it too complex would be to make it time based.

So when a key is pressed, the listener wont trigger the function again on a key press untill x seconds has passed.
Yes, I'm currently playing with this idea as it does seem the easier solution.