title: KeyPress event in C#?
body: <p>This was very simple in VB.NET, I would just do the following</p>
  
  <pre><code>Private Sub TextBox1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
      If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Enter) Then
          e.Handled = True
          cmdOk.PerformClick()
      End If
  End Sub
  </code></pre>
  
  <p>I can't figure out how to do the equivalent in C#, not for the text box or the form in general. In Form1.cs, in the top left where the drop-down menu thing is, there is no option to generate a method for events (like how you can generate a Sub in VB), all I have is WindowsFormsApplication1.Form1</p>