I'd put an out put signal on another pin and power an LED that shows when the input on #4 is seen low. I suspect when the comm fails to register the 'space' on the PC the program is still running and you'll see the LED light change/toggle when the button is pushed. Perhaps your use of pin 4 is interfering with some other function, or the USB connection is failing to be restored or maintained over time until a full reset happens. This sounds like a short program you could post here as well.