I'm trying to identify non-printable characters and replace them with printable characters when scanning a barcode. Currently I'm getting some difficulties to identify all non-printable characters returning from the barcode scanner.
if (e.Key == Key.NumLock) // this is working
{
txtBarcode.Text += "<AI>";
txtBarcode.SelectionStart = i + 5;
e.Handled = true;
}
What I want to do is without checking is it a NumLock character, I need to check if it a special character like Numlock, Tab etc.. and then replace it with "AI" string. In other words, Commonly check If it is a non-printable character or not. And I need to do this on KeyDown event.
if (e.Key == Key.IsSpecialKey || e.Key == Key.IsNonPrintableKey) // this is what I want
{
txtBarcode.Text += "<AI>";
txtBarcode.SelectionStart = i + 5;
e.Handled = true;
}