Mail Archives: djgpp/2000/03/22/12:50:31
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 -