From: Speed Newsgroups: comp.os.msdos.djgpp Subject: Re: keyboard problem! Date: Tue, 02 Dec 1997 19:44:46 -0800 Organization: Erol's Internet Services Lines: 57 Message-ID: <3484D5AE.C28A5B10@remove-this.linux.dpilink.com> References: <65iu4r$ca1$1 AT yeppa DOT connect DOT com DOT au> <6608mn$g5u AT mtinsc05 DOT worldnet DOT att DOT net> NNTP-Posting-Host: 207.96.74.133 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Yes, but don't forget that each key emits a code when pressed, and another code when released. The keyup code is the (keydown code + 128), for anyone who was not aware. - Mark Walter Luke wrote: > > Paul Cartwright wrote: > > > does anyone know an algorithm that will get the scan code from a > > pressed key? > > The procedure below will gets the scan code from a pressed key, and > prints it to screen if it's not in the normal character set (i.e. if > it's something strange like the arrow keys). I hope this helps... > > #include "dos.h" > #include "stdio.h" > > char y; > > getkey(void) { > > union REGS r; > > r.h.ah = 0; > return int86(0x16, &r, &r); > > } > > main() { > > union scan { > int c; > char ch[2]; > } sc; > > do { > sc.c=getkey(); > if(sc.ch[0]==0) > printf("special key number %d \n", sc.ch[1]); > else > { > putchar(sc.ch[0]); > printf("\n"); > } > } while(sc.ch[0]!='q'); > > } > > -- > Walter Luke aka "Night Watchman" > > mailto:NightWatchman AT Sacrilege DOT com > Visit Shadows at http://shadows.sacrilege.com