Monday, November 9, 2009

C PROGRAM TO DISPLAY SCAN CODE & ASCII CODE FOR A KEY PRESSED BY YOU




/* THIS PROGRAM PRINTS SCAN CODE & ASCII CODE
        FOR A KEY PRESSED BY YOU
 WE USE "ISR METHOD" TO FIND THE CODES HERE

*/

 
 

#include< stdio.h>
#include< conio.h>
#include< dos.h>
void main()
{
 union REGS inregs,outregs;
 int a,b;
 char c='a';
 while(c!='y')
 {
  clrscr();

  printf("\n--------------------------------------------------------------------\n");
  printf("\nTHIS PROGRAM PRINTS SCAN CODE & ASCII CODE FOR A KEY PRESSED BY YOU\n");
  printf("\n--------------------------------------------------------------------\n");
  printf("\npress a key...\n");


  int86(22,&inregs,&outregs);  //22 is for keyboard interrupt service request
  a=outregs.h.ah;   //higher 8 bits of AX register i.e ah stors the value of SCAN CODE
  b=outregs.h.al;   //lower 8 bits of AX register i.e al stors the value of ASCII CODE


/*  If we wish to find what key user pressed it can be
  found by the help of the value of 'a' and 'b' by using the
*/  following switch case statement


/*  switch(a)
  {
   case 15: printf("\nTab Pressed");break;
   case 71: printf("\nHome Pressed");break;
   case 72: printf("\nUp arrow Pressed");break;
   default: printf("\nscan code = %d   %d",a,b);break;
  }
*/

  printf("\nscan code = %d   ascii code = %d",a,b);



  printf("\n\n\n\npress [Esc] to exit or [Enter] to continue...");


  if(a==1)
   c='y';
  getch();
 }
}

1 comment:

  1. How to Play Pai Gow Poker | BetRivers Casino - Wolverione
    Pai worrione Gow 토토 사이트 Poker is an online version of a traditional https://septcasino.com/review/merit-casino/ table 바카라 사이트 game in which players place bets in the background. Pai Gow Poker uses only the symbols from 바카라 사이트 a

    ReplyDelete