If your getkey subroutine doesn't return if no keys are pressed, it'll do what you are describing.

But it's hard to say whats wrong without seeing the getkey subroutine.
<br>