In the first piece of code you override
OnKeyDown
. This is done when you are a derived class and need to do something yourself when this event occurs.
In the second piece of code you handle the event with the
EditBox_KeyDown
. You need to make sure that you implement the event handler for each control.
If you want to get the keydown event for the overall form (no matter what control is focused), you set the
KeyPreview
of the
Form
to
True
and create a handler for the form keydown event. Have a look here for more info:
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.keypreview%28v=vs.71%29.aspx[
^]
Good luck!