Re: Key pressed.
Posted in 1998
Topics: General Discussion
I recognize your note from the times it was sent in Spanish; thanks for posting in English. The irony of this is, though, that this is properly a question for comp.lang.c. However, I think you simply need to use fcntl on stdin to set O_NDELAY to turn blocking off for stdin; then getchar() will work. I dimly recall a function rgetkey() from somewhere (MS-DOS, maybe?) that may have sister functions to do this also. Then again, my C is somewhat rusty, so this may be somewhat off base. David jhernandez@geuropa.com (Juan Manuel Hernandez del Olmo) on 10/07/98 01:13:26 AM To: informix-list@iiug.org cc: (bcc: David Coburn/ISG/WVUS/WorldVision) Subject: Key pressed. Key pressed. I need a C function that returns the key a user has pressed, without awaiting for the user to press. Or, I would need to modify the following function, so it doesn't wait for the pulsation. /* It waits until the pulsation of a key, then it returns its INTEGER code */ int fgl_getkey( int args ) { extern short _acckey; short keyhit; short eflastkey; eflastkey = (( keyhit = rgetkey() ) == _acckey ) ? 2016 : keyhit; clrmsg(); retlong(( long ) eflastkey ); return( 1 ); }