Arsen Zahray
Arsen Zahray

Reputation: 25297

Check if a key in WPF OnKeyUp event is a special character

I've created a OnKeyUp method to RichTextControl, and I want to ignore all keys, which are special characters (like shift, control, alt etc).

One way to do that is to enumerate all the characters that I want to ignore, but I'm wondering, if there's something like IsSpecialKey function somewhere, that I can use in this context

Upvotes: 0

Views: 1358

Answers (1)

david.s
david.s

Reputation: 11403

I think you can use the Char.IsControl method on the KeyCode property of the KeyEventArgs like this:

KeysConverter kc = new KeysConverter();
if (!Char.IsControl(Convert.ToChar(kc.ConvertToString(e.KeyCode))))
{
    ...
}

Upvotes: 1

Related Questions