you can listen to the PreviewTextInput event instead of KeyDownEvent:
myTextBox.PreviewTextInput += PreviewTextInputHandler;
and then:
private void PreviewTextInputHandler(Object sender, System.Windows.Input.TextCompositionEventArgs e) { e.Handled = !AreAllValidChars(e.Text); }
this is one of the functions that I use in my application, you will have to tweak it a bit to check the correct characters, but you know how to do it.
as for getting% caracter, you just need to write something like:
if (e.Text == '%') ...;
David source share