title: Enter key press in C#
body: <p>I tried this code:</p>
  
  <pre><code>private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
  {
      if (Convert.ToInt32(e.KeyChar) == 13) 
      {
          MessageBox.Show(" Enter pressed ");
      }
  }
  </code></pre>
  
  <p>and this:</p>
  
  <pre><code>private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
  {
      if (e.KeyChar == Convert.ToChar(Keys.Enter))
      {
          MessageBox.Show(" Enter pressed ");
      }
  }
  </code></pre>
  
  <p>and this:</p>
  
  <pre><code>private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
  {
      if (e.KeyChar == Keys.Enter)
      {
          MessageBox.Show(" Enter pressed ");
      }
  }
  </code></pre>
  
  <p>but they're not working...</p>
  
  <p>When I write something and press <kbd>Enter</kbd>, it doesn't work. It only highlights my text.</p>