getch

Obtains the next available keystroke from the current screen

Local Servers:blocking
Remote Servers:N/A
Classification:Other
Service:Device I/O

Syntax

  #include <nwconio.h>  
   
  int getch  (void);
  

Return Values

This function returns a value of EOF when an error is detected. Otherwise, the getch function returns the value of the keystroke (or character).

When the keystroke represents an extended key (for example, a function key, a cursor-movement key, or the Alt key with a letter or a digit), a value of 0 is returned, and the next call to getch returns a value for the extended function. When an error occurs, errno is set.

Remarks

The getch function reads from the current screen. Nothing is echoed on the screen ( getche echoes the keystroke, if possible). When no keystroke is available, the function waits until a key is depressed.

Use the kbhit function to determine if a keystroke is available.

See Also

getche, kbhit

Example

  #include <nwconio.h>  
  main ()  
  {  
     int   keyStroke;  
     keyStroke = getch ();  
  }