title: C# Web browser Enter key
body: <p>I'm having a problem using the Enter key to navigate the browser. </p>
  
  <pre><code>protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
  {
      switch (keyData)
      {
          case Keys.Enter:
              go_Click.PerformClick();
              return true;
      }
      return false;
  }
  </code></pre>
  
  <p>And my <code>go_Click</code>:</p>
  
  <pre><code>private void go_Click(object sender, EventArgs e)
  {
      //declares URL as string variable
      string url = textbox.Text;
  
      //if statment to determine if URL is correct
      if (url == "")
      {
          MessageBox.Show("Please enter a valid URL!");
      }
  
      if (url.Substring(0, 3) == "www")
      {
          url = "http://" + url;
          webBrowser1.Navigate(url);
      }
  }
  </code></pre>
  
  <p>It returns an error, the errors states that is a method, which is not valid in the given context.</p>