www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1993/10/28/05:23:50

From: kunst AT prl DOT philips DOT nl
Subject: Re: getch without echo?
To: fb33 AT rummelplatz DOT uni-mannheim DOT de (Christoph Kuhmuench)
Date: Thu, 28 Oct 1993 10:06:05 +0100 (MET)
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu (DJGPP users list)

> 
> I'd like to read characters from the keyboard without waiting for <RETURN>
> or if possible without waiting at all. The pressed key shouldn't be echoed
> to the screen (like getche() in Turbo)
> 

#include <pc.h>

This include file defines a.o. the prototypes for the following functions:

int kbhit(void);
int getkey(void); /* ALT's have 0x100 set, 0xe0 sets 0x200 */
int getxkey(void); /* ALT's have 0x100 set */

getkey() does what you want, getxkey() is for reading extended keys.
Read the comments in <pc.h> for further details.
If you don't want to wait, use something like:

  int c = kbhit() ? getkey() : -1;  /* never waits */

Pieter.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019