delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/03/26/20:51:32

Date: Mon, 27 Mar 2000 06:39:29 +0500
Message-Id: <200003270139.GAA00835@midpec.com>
From: tr AT midpec DOT com (Prashant TR)
To: djgpp AT delorie DOT com
In-reply-to: <fsjsds05n8cfnliaje73ijgt4fc24sojsm@4ax.com> (message from
beyonddeath on Sun, 26 Mar 2000 16:00:19 GMT)
Subject: Re: using keyboard not line buffered
References: <fsjsds05n8cfnliaje73ijgt4fc24sojsm AT 4ax 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

beyonddeath <justhunt1234 AT home DOT com> proclaimed:

> what i need to do is allow my programs to use the arrowkeys and all
> other buttons while ignoring others for example
> 
> i want this while loop to continue forever until enter is hit
> 
> while(!keys() == ENTER)
> {
> printf("hit enter");
> }
> 
> If you can help great thanks im looking more for source cause its
> already been explained lots of times and i dont know assembler.
> 

Ok. Check this out (untested code)

#include <stdio.h>
#include <conio.h>

#define ENTER 13

int main()
{
	int key = 0;

	while (key != ENTER) {
	      key = getch();
	      if (!key) {
		 key = getch();
		 switch (key) {
			case 'H': printf("UP\n"); break;
			case 'P': printf("DOWN\n"); break;
			case 'K': printf("LEFT\n"); break;
			case 'M': printf("RIGHT\n"); break;
		 }
		 key = 0;
	      }
	}
	return 0;
}

- Raw text -


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