Well, I would use the KeyDown event, first of all.
Did you assign this method to the event handler, or did you just type/paste it in? What I mean is, did you use the Properties panel on the form editor to add the handler?
If you did, you should put a breakpoint in at your method, and see if it's actually being called.
Anyway, here's how I would handle it myself, to remove ambiguity:
- private void Form1_KeyDown(object sender, KeyEventArgs e)
-
{
-
switch (e.KeyCode)
-
{
-
case Keys.Z:
-
//whatever;
-
break;
-
case Keys.X:
-
//whatever;
-
break;
-
default:
-
//sanity check
-
break;
-
}
-
}