ron@clarity.Princeton.EDU (Ronald Beekelaar) (02/04/90)
Hi I have a very simple question, although I can't find the answer myself. How do you quietly test whether any key was pressed on the keyboard? I want to write a function that waits 10 seconds, if any key had been pressed, but doesn't wait at all, if none was pressed. Any help would be appreciated. -- ------ ron ------
brianh@hpcvia.CV.HP.COM (brian_helterline) (02/06/90)
>Hi > I have a very simple question, although I can't find the answer myself. How >do you quietly test whether any key was pressed on the keyboard? I want to >write a function that waits 10 seconds, if any key had been pressed, but >doesn't wait at all, if none was pressed. > Any help would be appreciated. >-- >------ >ron >------ >---------- In MSC 5.1 use the _bios_keybrd() function to accomplish what who want.
tris@alzabo.uucp (Tris Orendorff) (02/11/90)
ron@clarity.Princeton.EDU (Ronald Beekelaar) writes: >Hi > I have a very simple question, although I can't find the answer myself. How >do you quietly test whether any key was pressed on the keyboard? I want to >write a function that waits 10 seconds, if any key had been pressed, but >doesn't wait at all, if none was pressed. In Microsoft C V5.1 you can use the functions kbhit () and getch (). See section 4.8.3 in the run-time library reference book. -- Sincerely Yours Tris Orendorff tris@alzabo.uucp -----------------------------------------------------------------------
raw@math.arizona.edu (Rich Walters) (02/15/90)
In article <1990Feb10.190053.15413@alzabo.uucp> tris@alzabo.uucp (Tris Orendorff) writes: >ron@clarity.Princeton.EDU (Ronald Beekelaar) writes: > >>Hi > >> I have a very simple question, although I can't find the answer myself. How >>do you quietly test whether any key was pressed on the keyboard? I want to >>write a function that waits 10 seconds, if any key had been pressed, but >>doesn't wait at all, if none was pressed. > >In Microsoft C V5.1 you can use the functions kbhit () and getch (). >See section 4.8.3 in the run-time library reference book. > > Unix BSD has something similar but you must use cbreak mode which entails a lot of other overhead. Like reading the termcap/terminfo file and doing all kinds of setup yourself. Most of what you need is included, but I don't remember where off the top of my head. Richard Walter ------------------------------------------------------------------------------- Keep crunching those numbers -------------------------------------------------------------------------------