I tried:
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
streamWriter.Write(e.Key.ToString());
}
But I don't know how to convert a Key to string correctly. I also tried:
private void textBox1_TextInput(object sender, TextCompositionEventArgs e)
{
streamWriter.Write(e.Text);
}
But this event is not called. The farthest I went was:
private string previous = string.Empty;
private void textBox1_TextChanged(object sender, TextChangedEventArgs e)
{
var text = textBox1.Text.Substring(previous.Length);
streamWriter.Write(text);
previous = textBox1.Text;
}
But this has problems with character deletion, and many other cases. What should I do?