Skip to content

Events

srinath

Asked Sep 10, 2009, 11:50 PM EDT2 answers
Share
LinkedInX
hi,
what is the difference between keypress and enter events of a button.

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    The enter event occurs when the button gets focus.  Once the button has focus if you press a key you will activate the keypress event.
    You can test it by creating a button with two events like the following porley coded example ;) to see how the various events get handled.
    private void testkeypress(object sender, KeyPressEventArgs e)
    {
    textbox1.Text = "keypress";
    }
    private void testenter(object sender, EventArgs e)
    {
    textbox2.Text = "enter";
    }
    0
  • 0
    1) KeyPress = keydown + keyup;
    2) there is nearly no difference between keypress and enter evnets of a button in my mind.
      maybe 'enter' is only keydown event.
    0