After your delay statement, you could check for the presence of an entry in the keyboard buffer, and if there's anything, clear it out of there. You can find more information in the help under keypressed and readkey. I hope this put you in the right path.
Cheers,
Realm174