Well for starters what compiler are you using? Free Pascal, Delphi? And what API(s), if any are you using to control your screen/windowed modes and/or keyboard input?

This will at least give us a good starting point to try to help you out.