ftp.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/04/28/20:15:03

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
From: "Rafal 'Raf256' Maj" <admin AT raf256 DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: ANSI to read the keyboard before ENTER is pressed
Date: 29 Apr 2002 00:12:57 GMT
Organization: news.onet.pl
Lines: 30
Sender: raf256 AT poczta DOT onet DOT pl@
Message-ID: <Xns91FF16F4BDA60adminraf256com@>
References: <20020428235953 DOT 73775 DOT qmail AT web11306 DOT mail DOT yahoo DOT com>
Mime-Version: 1.0
X-Trace: news.onet.pl 1020039177 27737 (29 Apr 2002 00:12:57 GMT)
X-Complaints-To: abuse AT onet DOT pl
NNTP-Posting-Date: 29 Apr 2002 00:12:57 GMT
User-Agent: Xnews/5.03.24
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

PEDRO IZECKSOHN <izecksohn AT yahoo DOT com> wrote in 
news:20020428235953 DOT 73775 DOT qmail AT web11306 DOT mail DOT yahoo DOT com:

>    Hello, Is in ANSI some C function to read the keyboard
> for some key pressed, (even the special keys), before the
> ENTER is pressed ?

normaly no, but ther is some way to change terminal behawiour... I didn't 
test it, but maybe it will work :

#include <stdio.h>
#include <termios.h>
#include <unistd.h>

int main ()
  struct termios przed, po;
  int c;
  tcgetattr (0, &przed); 
  po = przed;
  po.c_lflag &= ~(ICANON | ECHO); 
  tcsetattr (0,TCSANOW, &po);
  do {
    c = getchar();
    printf ("Key: %c\n", c);
  } while (c != 'q');
  tcsetattr (0, TCSANOW, &przed); 
  return 0;

- Raw text -

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