ASCII and Scan code of a Key Press


24. Program to find the ASCII and scan code of a key press?

Program

#include<dos.h>
#include<conio.h>
#include<stdio.h>
void main()
{
 union REGS out;
 clrscr();
 printf("\n\nPress a key!!");
 int86(0X16,&out,&out);        //calling the interupt
 printf("\nCharaceter is:%c",out.h.al);        //printing the key pressed
 printf("\nASCII VALUE IS:%d",out.h.al);   //AL register contain the ASCII value
 printf("\nSCAN CODE IS:%d",out.h.ah); //AH register contain the SCAN code
 getch();
}

Output
                                                                               
Press a key!!                                                                   
Characeter is:H                                                                
ASCII VALUE IS:72                                                              
SCAN CODE IS:35 

No comments:

Post a Comment