69,381
社区成员
发帖
与我相关
我的任务
分享
#include<iostream>
#include<conio.h>
#include<stdlib.h>
#include<windows.h>
using namespace std;
int main()
{
char c;
while(1)
{
if(kbhit()!=0)
c=getch();
cout<<(int)c;
Sleep(1000);
system("cls");
}
return 0;
}
#include <conio.h>
#include <windows.h>
int main() {
int k;
while (1) {
if (kbhit()) {
k=getch();
if (0==k || 0xE0==k) k=k<<8|getch();
if (27==k) break;//按Esc键退出
cprintf("\r\n%04X\r\n",k);
}
Sleep(200);
cprintf(".");
}
return 0;
}
#include<iostream>
#include<conio.h>
#include<stdlib.h>
#include<windows.h>
using namespace std;
int main()
{
int c;
while(1)
{
if(kbhit()!=0) {
c=getch();
if (0==c || 0xE0==c) c=c<<8|getch();
if (27==c) break;//按Esc键退出
cout<<c;
while (kbhit()!=0) {
c=getch();
if (0==c || 0xE0==c) c=c<<8|getch();
}
}
Sleep(1000);
system("cls");
}
return 0;
}
while (1)
{
//if (kbhit() != 0)
c = getch();
cout << (int)c;
Sleep(1000);
while (kbhit()!=0) {//----使用while()语句把Sleep()期间所有的按键读取出来
getch();
};
system("cls");
}