In WPF, I have a RichTextBox with a flow document inside. I need to know when the user presses a spacebar. The code below works and shows a messagebox each time a key is pressed but not for spacebar. If you press F e.g. a messagebox with F is displayed but when space is pressed the caret just moves to the next position.
private void RichTextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
MessageBox.Show(e.Text);
}
What am I missing here? Thanks for your time :)