Detecting keypress 
Author Message
 Detecting keypress

Quote:

>Hi,

>I want to be able to detect a keypress while doing something else under
>Unix (though something universal would help). Most PC librarys have a
>function kbhit() that works but I havn't found the equivalent under
>Unix.

>For example:

>while (do_something) {

> // work

> if (kbhit()) {
>  c = getch();

>  // do something based on c
> }
>}

From the FAQ list, RTFM.mit.edu:pub/usenet/comp.lang.c/* :

19.2:   How can I find out if there are characters available for reading
        (and if so, how many)?  Alternatively, how can I do a read that
        will not block if there are no characters available?

A:      These, too, are entirely operating-system-specific.  Some
        versions of curses have a nodelay() function.  Depending on your
        system, you may also be able to use "nonblocking I/O", or a
        system call named "select" or "poll", or the FIONREAD ioctl, or
        c_cc[VTIME], or kbhit(), or rdchk(), or the O_NDELAY option to
        open() or fcntl().  See also question 19.1.

Quote:
>If you can help please email me.

If you need personalized service, hire a consultant.

Quote:
>Thanks,

>Stu.

You welcome,

Maurizio Loreti                       http://www.*-*-*.com/



Tue, 24 Feb 1998 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. How To Detect KeyPress.

2. Detecting keypress when the focus is on CButton

3. Detect keypress in dialog-based

4. Detecting A Keypress

5. HELP! Keypress detect

6. Detecting a keypress

7. HOW TO: detect a keypress

8. Detecting delete keypress in OnChar

9. combobox and keyPress Event

10. Convert keypress to upper case

11. object sender keypress (c# newbie)

12. Tab KeyDown-KeyPress trapping

 

 
Powered by phpBB® Forum Software