title: Using document.write in event handler?
body: <p>I am experimenting with HTML and JavaScript. The following code should print something when entering a keystroke in a textbox:</p>
  
  <pre><code>&lt;html&gt;
      &lt;body&gt;
          &lt;input type="text" id="commandInput" name="command" size="50" /&gt;
          &lt;script type="text/javascript"&gt;
              var commandInput = document.getElementById("commandInput");
              commandInput.onkeydown = function (evt) {
                  document.writeln("Test");
              };
          &lt;/script&gt;    
  
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>For some reason the textbox disappears when entering a keystroke, leaving nothing but a white page.</p>
  
  <p>Any ideas why this is happening?</p>