title: onKeypress Enter Key event on textfield not working in Chrome
body: <p>I have a question along the same vein as <a href="https://stackoverflow.com/questions/3497133/handling-the-enter-return-key-in-chrome">the one asked here</a> regarding how the enter key is handled in chrome. </p>
  
  <p>The effect I am trying to accomplish is to allow the enter key to call a click event of one a button while focus in within the current field. To accomplish this I am using the following code:</p>
  
  <p>javascript:</p>
  
  <pre><code> &lt;script type="text/javascript"&gt;
  //attempting to capture keypress for chrome here but this is not working
          $("#txtContainer").keypress(function (e) {
              if (e.keyCode == '13') {
                  e.preventDefault();
                  doClick(buttonname, e);
                  return false;
              }
          });
  
          function doClick(buttonName, e) {
  
              var key;
              if (window.event)
                  key = window.event.keyCode;     //IE
              else
                  key = e.which;     //firefox
  
              if (key == 13) {
                  var btn = document.getElementById(buttonName);
                  if (btn != null) { 
                      btn.click();
                      event.keyCode = 0
                  } 
              }
          }
  &lt;/script&gt;
  </code></pre>
  
  <p>within the aspx</p>
  
  <pre><code> &lt;form id="form1" runat="server"&gt;
      &lt;div&gt;
      &lt;asp:LinkButton ID="newBtn" runat="server" OnClick="btnLogin_Click" Text="ASP Link" /&gt;
      &lt;asp:TextBox ID="txtContainer" runat="server" Width="100" /&gt;
      &lt;asp:Label ID="time_lbl" runat="server" /&gt;
      &lt;/div&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>and within the code behind
  aspx.cs</p>
  
  <pre><code> protected void Page_Load(object sender, EventArgs e)
          {
              if (!IsPostBack)
              {
                  txtContainer.Attributes.Add("onKeyPress", "doClick('" + newBtn.ClientID + "',event)");
              }
  
          }       
  
          public void btnLogin_Click(object sender, EventArgs e)
          {
              time_lbl.Text = txtContainer.Text;
          }
  </code></pre>
  
  <p>The above code works fine in FF and IE however chrome continues to submit the entire form vs. capturing the keypress on the enterkey.</p>
  
  <p>Thank you for any suggestions.</p>