title: Prevent multiple firing of keydown events C#
body: <p>I want to allow the user to send his message when he press enter in the textbox.
  I went to search and im using the sample codes below.</p>
  
  <p>Now the problem is when i press enter, the event is triggered more than once like about 4-5 times.</p>
  
  <p>Someone else suggested to use keyup. I have tried keyup, keydown and keypress. All have the same problem.
  How do i prevent it from firing the event more than once? </p>
  
  <pre><code>private void tbxAnswer_TextChanged(object sender, EventArgs e)
      {
          tbxAnswer.KeyUp += new KeyEventHandler(tbxAnswer_KeyUp);
      }
  
      private void tbxAnswer_KeyUp(object sender, KeyEventArgs e)
      {
          if (e.KeyValue == (char)13)
          {
  
              MessageBox.Show("Hello");
  
          }
      }
  </code></pre>
  
  <p>Thank you!</p>