c语言抬起按键,c语言获得键盘的按键
該樓層疑似違規已被系統折疊?隱藏此樓查看此樓
TC 2.0版
#include
#include
int main()
{
int key;
while(1)
{
key=getch();/*用于去掉第一個字節*/
if(key==27) break; /*如果是ESC退出*/
if(key>31 && key<127) /*如果不是特殊鍵*/
{printf("You have pressed %c Press ESC to exit!\n",key);continue;}
key=getch();
if(key==72) printf(" UP Press ESC to exit!\n");
if(key==80) printf(" DOWN Press ESC to exit!\n");
if(key==75) printf(" LEFT Press ESC to exit!\n");
if(key==77) printf(" RIGHT Press ESC to exit!\n");
}
return 0;
}
VC 6.0版
#include
#include
int main()
{
int key;
while(1)
{
key=getch();
if(key==27) break;
if(key>31 && key<127) /*如果不是特殊鍵*/
{printf("按了 %c 鍵 按 ESC退出!\n",key);continue;}
key=getch();
if(key==72) printf("按了 上 鍵 按 ESC退出!\n");
if(key==80) printf("按了 下 鍵 按 ESC退出!\n");
if(key==75) printf("按了 左 鍵 按 ESC退出!\n");
if(key==77) printf("按了 右 鍵 按 ESC退出!\n");
}return 0;
}
總結
以上是生活随笔為你收集整理的c语言抬起按键,c语言获得键盘的按键的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 法拉第未来称已收到300多份免订金预订
- 下一篇: 中南民族大学c语言报告,中南民族大学信C