I`m developing this application that need to read every key stroke while the application is focused.
I can read all keys except for 3 keys: Space bar, Enter and backspace.
This is a code snippet form my project:
XAML File:
<TextBox Height="108" HorizontalAlignment="Left" Margin="12,12,0,0" Name="textBox1" VerticalAlignment="Top" Width="354" AcceptsReturn="True" AcceptsTab="True" KeyDown="textBox1_KeyDown" IsReadOnly="False" IsEnabled="True" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto" />
CS File:
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Return || e.Key == Key.Space)
MessageBox.Show("" + e.Key);
}