I am making program that every pressed key will be saved into text file. My goal is to save every keystroke in new line so for example if you press "x" and then "y" I want this "x" be saved in first line and "y" in second.
while (true)
{
Thread.Sleep(10);
for (int i = 0; i < 255; i++)
{
int keyState = GetAsyncKeyState(i);
if (keyState == 1 || keyState == -32767)
{
Console.WriteLine((Keys)i);
string key = Convert.ToString((Keys)i);
//StreamWriter writer = new StreamWriter(pathTxt); <-- this is what I have tried but it's all the time replacing keystroke in first line
//writer.WriteLine(key + Enviroment.NewLine);
//writer.Close();
break;
}
}
}
What I have tried:
My goal is to save every keystroke in new line.