Question

I'm using a keylogger to capture keys as they are pressed.

It works fine but not for special chars as "@, +£%*¨¨" .. etc

private void Test_KeyPress(object sender, KeyPressEventArgs e)
{
    if(e.KeyChar == (char)Keys.Return)
        WriteToTextFile(sb.ToString());
    sb.Append(e.KeyChar);
}

Is it also possible to delete chars if users pressed Backspace key?

Was it helpful?

Solution

Try method OnPreviewKeyDown(PreviewKeyDownEventArgs e) if you are working on a control. I also had the problem, that not everything was captured with OnKeyPress.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top