Frage

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?

War es hilfreich?

Lösung

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top