本文介绍了如何使用C检测特殊键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hii,
我需要使用C代码来检测F1键的按下情况
我尝试了此代码,但不适用于F1
Hii,
I need to detect the press of F1 key using C code
I tried this code, but it wont work for F1
printf("Press F1 key to continue\n");
while(getch() == 0x3b)
{
printf("\n F1 Pressed");
getch();
}
推荐答案
printf("Press F1 key to continue.\n");
while (true)
{
int c = _getch();
if (c != 0x00 && c != 0xE0) continue;
if (_getch() == 0x3B) break;
}
这篇关于如何使用C检测特殊键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!