From: Walter Luke Newsgroups: comp.os.msdos.djgpp Subject: Re: keyboard problem! Date: Tue, 02 Dec 1997 01:02:18 -0500 Organization: Shadows http://shadows.sacrilege.com Lines: 53 Message-ID: <6608mn$g5u@mtinsc05.worldnet.att.net> References: <65iu4r$ca1$1 AT yeppa DOT connect DOT com DOT au> Reply-To: NightWatchman AT Sacrilege DOT com NNTP-Posting-Host: 12.68.12.119 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 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