title: Input type text and onKeyDown not working under IE
body: <p>I am writing a WWW application, it has to run under IE. I have the problem with the code that runs under Firefox, but I can't get it running under IE.</p>
  <p>// JS code</p>
  <pre><code>function test()
  {
      if (window.event.keyCode == 13)
          window.location.assign(&quot;myPage.php&quot;);
  }
  </code></pre>
  <p>I've tried some similar ways around <code>window.location</code> and <code>location.href</code>, also <code>document.location</code>. I've read that IE has problems with that, so I ask for a solution.</p>
  <p>The goal is, that page reloads after typing in some text into <code>&lt;input type='text' name='item_code' onKeyDown='test()'&gt;</code> and click <kbd>enter</kbd>. So the result is similar to pressing submit type button below the text input.</p>
  <p>Within IE it reloads the same page and nothing happens. In Firefox it works correctly.</p>
  <p><strong>UPDATE 1:</strong></p>
  <p>Tried solution given by bobince.</p>
  <pre><code>&lt;input type='text' name='item_code'&gt;
  
  &lt;script type='text/javascript' &gt;
   
  document.getElementsByName('item_code')[0].onkeydown = function(event)
  {
      if (event == undefined) { event = window.event; }
      if (event.keyCode == 13) { window.location = 'myPage.php'; }
          
      alert('1');
  }
      
  &lt;/script&gt;&quot;;
  </code></pre>
  <p>The problem is, that if there is <code>alert('1');</code> line, page shows alert and redirects, if there isn't <code>alert('1');</code> line, page just reloads to itself. I don't know what is the problem here?</p>
  <p><strong>UPDATE 2:</strong></p>
  <p>I'am pasting what finally works for me.</p>
  <pre><code>&lt;form action='mainPage.php' method='POST'&gt;
      &lt;input type='text' name='item_code'&gt;
  &lt;/form&gt;
  
  &lt;script type='text/javascript' &gt;
      document.getElementsByName('item_code')[0].onkeydown= function(event)
      {
          if (event == undefined)
          {    
              event = window.event;
          }
  
          if (event.keyCode == 13)
          {
              var js_item_code = document.getElementsByName('item_code')[0].value;
              window.location = 'myPage.php?item_code='+js_item_code;
              return false;
          }
      };
  &lt;/script&gt;
  </code></pre>