title: Visual Studio C# Capturing Enter Key In Textbox
body: <p>I am trying to capture the Enter key in a Windows Forms Textbox.  I got this fragment of code from a tutorial:</p>
  
  <pre><code>private void textBox1_KeyDown(object sender, KeyEventArgs e)
  {
      //
      // Detect the KeyEventArg's key enumerated constant.
      //
      if (e.KeyCode == Keys.Enter)
      {
          MessageBox.Show("You pressed enter! Good job!");
      }
      else if (e.KeyCode == Keys.Escape)
      {
          MessageBox.Show("You pressed escape! What's wrong?");
      }
  }
  </code></pre>
  
  <p>but now my code throws a compile/build error:</p>
  
  <pre><code>The event 'System.Windows.Forms.Control.Enter' can only appear on the left hand
  side of += or -=    Line 44 Column 84
  </code></pre>
  
  <p>On the one hand I don't understand the error message.  On the other hand line 44 is a blank line having only a newline character.</p>
  
  <p>Any advice is appreciated.</p>
  
  <p>Regards.</p>