如何在C中获取alt和控制键的扫描码?

时间:2012-12-22 19:31:56

标签: c

  

可能重复:
  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。我不明白,请解释一下。

1 个答案:

答案 0 :(得分:0)

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