How to determine if KeyCode is printable character

I am handling the key down event on one of my controls. If the key pressed is an actual input (alphabetic, numeric, or symbol of some kind) I want to append it to a string I have. If it is a control character (enter, escape, etc..) I don't want to do anything.

Is there a quick and easy way to determine if the key code is a printable character or a control character?

Currently I am doing

if (e.KeyCode == Keys.Enter)
      {
        e.Handled = false;
        return;
      }

But I know there are probably a few more keys I don't care about that do something important in the system handler, so I don't want to handle them.

9
задан captncraig 3 September 2010 в 20:04
поделиться