delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/03/22/12:50:31

Date: Wed, 22 Mar 2000 22:37:49 +0500
Message-Id: <200003221737.WAA01015@midpec.com>
From: tr AT midpec DOT com (Prashant TR)
To: djgpp AT delorie DOT com
In-reply-to: <8ba1va$943$1@nnrp1.deja.com> (wroot@my-deja.com)
Subject: Re: ncurses
References: <8ba1va$943$1 AT nnrp1 DOT deja DOT com>
Reply-To: djgpp AT delorie DOT com
Errors-To: dj-admin AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

wroot AT my-deja DOT com proclaimed:

> How can I read one keystroke from the keyboard (including but
> not limited to arrow movements, PgUp, PgDn, Del)? I've heard
> it is done with ncurses/curses. If someone could tell me
> which function, header file and namespace I should use, I would
> appreciate it.

Try this code:

int x;

x = getch();
if (!x) {
   x = getch();
   if (x == 'I') printf("PGUP pressed\n");
}

--------
The way it works:

When you press any of the keys like PGUP, etc., an ascii and scan code are
generated. The ASCII code is always zero, so the scancode tells you the key
pressed.

You could also use the _bios_keybrd() function, but I prefer this way of doing
it.

- Raw text -


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