Possible Duplicate:
How to read or capture Ctrl+some key or Alt+some key in C?




代码段:

char ks;
ks=getch(); // getting the keystroke : if non ascii then 2 bytes returned : 1st 0 then //scancode
if(ks==0) // if there's no ascii then get the scan code
ks=getch();
printf("%d",ks); // would print ascii if ks !=0 else scan code
//end


alt和控制键不输出,而ctrl + e输出为5。我不明白,请解释。

最佳答案

Ctrl, Alt, Shift不是字符,在要读取的字符流中找不到。

关于c - 如何获取C中的alt和控制键的扫描代码? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14005907/

10-10 17:24