delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/03/27/11:09:54

From: beyonddeath <justhunt1234 AT home DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: using keyboard not line buffered
Message-ID: <27uudsce1g54pujkb3a7ajam89n1g7d0h8@4ax.com>
References: <fsjsds05n8cfnliaje73ijgt4fc24sojsm AT 4ax DOT com> <200003270139 DOT GAA00835 AT midpec DOT com>
X-Newsreader: Forte Agent 1.7/32.534
MIME-Version: 1.0
Lines: 51
Date: Mon, 27 Mar 2000 13:07:40 GMT
NNTP-Posting-Host: 24.112.65.173
X-Complaints-To: abuse AT home DOT net
X-Trace: news2.rdc1.on.home.com 954162460 24.112.65.173 (Mon, 27 Mar 2000 05:07:40 PST)
NNTP-Posting-Date: Mon, 27 Mar 2000 05:07:40 PST
Organization: @Home Network Canada
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Thanks, i found libkb which seems to work for what i need, getch on my
system seems to wait for me to enter a key each time through the loop
which is not what i need it for.

Thanks anyway

On Mon, 27 Mar 2000 06:39:29 +0500, tr AT midpec DOT com (Prashant TR) wrote:

>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