Mail Archives: djgpp/1997/12/02/23:31:15
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
- Raw text -