如果你用的是VC6.0来编译的话 是没有这个头文件的 不果我们可以用其他的办法来处理按键
下面是响应上下键的
int ch;
ch=getch();
if(ch==224)
{
case 72://Up
break;
case 80: //down
break;
case 75://left
break;
case 77://right
break;
default:
break;
}
所需头文件为
换个方式,用kbhit(),配合GetKeyState()即可获得你想要的结果
例如:
#include
#include
int main( void )
{
while( !_kbhit() )
_cputs( "Hit me!! " );
printf( "\nKey struck was '%c'\n", _getch() );
}
上下左右可以这样:
#include
#include
int main()
{
while (1)
{
if(getch()==224)
{ switch (getch())
{
case 72: printf("The key you Pressed is : ↑ \n");break;//Up
case 80: printf("The key you Pressed is : ↓ \n");break;//down
case 75: printf("The key you Pressed is : ← \n");break;//left
case 77: printf("The key you Pressed is : → \n");break;//right
default:break;
}
}else{printf("Not direction keys \n");}
}