Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!hplabs!hpfcso!hplvec!richd From: richd@hplvec.LVLD.HP.COM (Rich Dykstra) Newsgroups: comp.lang.c Subject: Re: NOVICE question: How to know when a key is pressed Message-ID: <690002@hplvec.LVLD.HP.COM> Date: 13 Apr 91 16:50:03 GMT References: <1991Apr11.155200.12819@ericsson.se> Organization: Hewlett-Packard Co., Loveland, CO Lines: 31 On hp systems, two things must be done - change the terminal driver configuration, and modify the terminal straps so that escape sequences are passed to the host instead of being acted upon locally by the terminal. Here is code I created several years ago, I think it is still relevant: (refer to termio(7)) static struct termio tcorg_block; static struct termio tcact_block; static struct f_rec_t tcara[TCARA]; struct key_rec{ int key; char chr}; tcinit() { int result; printf("%c&s1A", 27); /* transmit esc sequences*/ result = ioctl(0, TCGETA, &tcorg_block); /* driver data (origial) */ result = ioctl(0, TCGETA, &tcact_block); /* driver dat (to mess with)*/ tcact_block.c_lflag &= ~ICANON & ~ECHO; /* no echo or pre process*/ tcact_block.c_cc[VEOF] = 1; /* read 1 char at a time*/ result = ioctl(0, TCSETA, &tcact_block); /* set the driver */ tcmove(0,0,'S'); /* clear the screen */ } As an alternative, you may want to consider using the curses package. It does this as well as offering other slick interfacing features, such as terminal type independence.