Try porting from http://c-faq.com/osdep/kbhit.txt