title: How can I detect the Enter key in Firefox?
body: <p>I am able to successfully detect the <kbd>Enter</kbd> key in Internet Explorer 10, Chromium and Opera, but not in Firefox.</p>
  
  <p>I have found a few pages on here, though they do not work in Firefox either. Am I doing something wrong, here?</p>
  
  <p>TypeScript:</p>
  
  <pre><code>function HandleKeyPress(e) {
      var key = e.keyCode || e.which;
  
      if (key == 13) {
          // We got this.
          var textbox = &lt;HTMLInputElement&gt;document.getElementById("tbox");
          sayHello(textbox.value);
      }
  }
  </code></pre>
  
  <p>Resulting JavaScript (identical):</p>
  
  <pre><code>function HandleKeyPress(e) {
      var key = e.keyCode || e.which;
      if(key == 13) {
          var textbox = document.getElementById("tbox");
          sayHello(textbox.value);
      }
  }
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;input type="text" value="dfgdfgdfg" id="tbox" onkeypress="HandleKeyPress(event)" /&gt;
  </code></pre>
  
  <p>I can't use any external libraries, I have to do this in pure JavaScript (or a language that compiles to pure JS).</p>
  
  <hr/>
  
  <h1>Update:</h1>
  
  <p><hr/>
  I just installed Firebug and in the Consolw pane I noticed (just after pressing the <kbd>Enter</kbd> jey on the textfield:</p>
  
  <pre><code>http://localhost:1058/Default.cshtml?someValue=dfgdfgdfgkjkhj
  
  
  &lt;p&gt;You said: dfgdfgdfgkjkhj&lt;/p&gt;
  </code></pre>
  
  <p>See below for the pic:</p>
  
  <p><img src="https://i.stack.imgur.com/w52Sp.png" alt="enter image description here"></p>
  
  <p><em>Notice</em> that the page itself has not updated the value of the <code>response</code> paragraph to what was entered in the textbox, <strong>but</strong>, Firebug does indeed say that it was successfully posted.</p>
  
  <p>Now, since this code works on every other browser (IE, Chrome/Canary and &lt;, Opera, Safari), my question is, maybe Firefox <strong>is</strong> detecting the key event, but the part that isn't working is after that?</p>