Post: [C++] Keyboard monitoring, without waiting for input
02-13-2011, 01:29 AM #1
(adsbygoogle = window.adsbygoogle || []).push({});
    #include<iostream>
#include<windows.h>
#include<conio.h>

using namespace std;

int main()
{
short int speed = 100;
short int ascii[2];

cout<<"Press F1 to change monitor per second!";
Sleep(2000);

system("CLS");

for(;Winky Winky
{
for(;Winky Winky
{
if(kbhit())
{
ascii[0]=getch();
if(!ascii[0])
{
ascii[1]=getch();
if(ascii[1]==59)
{
break;
}
else
{
cout<<"Key monitor:\t0\t"<<ascii[1];
}
}
else
{
cout<<"Key monitor:\t"<<ascii[0]<<"\tCharacter: "<<char(ascii[0]);
}

}
else
{
cout<<"Key monitor:\tNULL";
}
cout<<endl;
Sleep(speed);
}
cout<<"Enter how many monitors per second Default(10): ";
cin>>speed;

speed = (1000/speed);
}
}

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo