keyscan wanted
William Kucharski
kucharsk at uts.amdahl.com
Tue Jun 6 03:53:43 AEST 1989
In article <607 at wn2.sci.kun.nl> medfys at wn2.sci.kun.nl (Victor Langeveld/Tjeerd Dijkstra) writes:
>There is no need to know what hardware this should be working on.
>Mr Charles Thayer (Thanks again, Charles!) gave me a perfect solution:
>
>int key_pressed()
>{
> int mask=1;
> struct timeval wait;
>
> wait.tv_sec=0;
> wait.tv_usec=0;
> return (select(1,&mask,0,0,&wait));
>}
>
>This can be used as e.g. if(!key_pressed) { do stuff} else { key
>handling}. Works fine! (As is should (?) on any unix machine)
As long as the machine in question has select(2), which automatically assumes
a UNIX with some BSD extensions - SYSV hacks will have to use poll(2) instead.
--
William Kucharski
ARPA: kucharsk at uts.amdahl.com
UUCP: ...!{ames,decwrl,sun,uunet}!amdahl!kucharsk
Disclaimer: The opinions expressed above are my own, and may not agree with
those of any other sentient being, not to mention those of my
employer. So there.
More information about the Comp.unix.questions
mailing list