#include<stdio.h>
#include<bios.h>
#include<graphics.h>
#define UP 0x4800/*这里是定义按键码,这个可以在资料中查到*/
#define DOWN 0x5000
#define RIGHT 0x4d00
#define LEFT 0x4b00
#define ESC 0x011b
init(){
int gd=DETECT,gm;
initgraph(&gd,&gm,"c\tc");
cleardevice();
}/*初始化图形驱动*/
void main(){
int key;
clrscr();
init();
setbkcolor(RED);/*置背景色为红色*/
printf("Key the ESC key to exit.\n");
while(1){
printf("Please input the way key:");
switch(bioskey(0)){
case UP: printf("You key the up key!\n");break;
case DOWN: printf("You key the down key!\n");break;
case LEFT: printf("You key the left key!\n");break;
case RIGHT: printf("You key the right key!\n");break;
case ESC:exit(0);
default: printf("You don't key the way key!\n");break;
}
}
getch();
}