Well, I currently use the KeyPress handler to do this:
private void OnKeyPress(object sender,KeyPressEventArgs e) { switch (e.KeyChar) { case '\x0d': //handle the return key break; } } private void OnKeyDown(object sender,KeyEventArgs e) { switch (e.KeyCode) { case Keys.Return: //handle the return key break; } }
The KeyDown (simular KeyUp) code I added to show that the key is also available in these handlers, as said for some reason I ended up handling the key in the KeyPress handler, but other options exist as well. I hope this helps. |