title: Javascript: Function parameter not defined error
body: <p>Fooling around with a script to make a random square move on any web page with arrow keys. I'm encountering an error saying &quot;e&quot; does not exist.</p>
  <pre><code>var page = document.getElementsByTagName(&quot;body&quot;)[0];
  var bruhmoment = document.createElement(&quot;div&quot;);
  bruhmoment.style.height = &quot;100px&quot;;
  bruhmoment.style.width = &quot;100px&quot;;
  bruhmoment.style.display = &quot;block&quot;;
  function getColor(){
      var color = &quot;#&quot;;
      for(var i = 0; i &lt; 6; i++){
          color += ( Math.round(Math.random()) * 9 );
      }
      return color;
  }
  bruhmoment.style.backgroundColor = getColor();
  bruhmoment.style.zindex = 1e9;
  bruhmoment.id = &quot;bruhmoment&quot;;
  bruhmoment.style.marginLeft = &quot;0px&quot;;
  bruhmoment.style.marginBottom = &quot;100px&quot;;
  bruhmoment.xaxis = 0;
  bruhmoment.yaxis = 0;
  function move(e){
      switch(e.which){
          case 39:
              xaxis += 10;
              bruhmoment.style.marginLeft = xaxis + &quot;px&quot;;
              break;
          case 37:
              xaxis -= 10;
              bruhmoment.style.marginLeft = xaxis + &quot;px&quot;;
              break;
          case 38:
              yaxis += 10;
              bruhmoment.style.marginBottom = yaxis + &quot;px&quot;;
              break;
          case 40:
              xaxis -= 10;
              bruhmoment.style.marginBottom = yaxis + &quot;px&quot;;
              break;
          case 67:
              bruhmoment.style.backgroundColor = getColor();
              break;
      }
  }
  page.onkeydown = move(event);   
  page.appendChild(bruhmoment);
  </code></pre>
  <p>Out of all the things in this code that could possibly be an error, I'm not sure how JavaScript chose that specific error to have a quarrel with. Could someone enlighten me?</p>