title: What exactly is the parameter e (event) and why pass it to JavaScript functions?
body: <p>Well, when I learned JavaScript, all the books and Internet articles I read showed code passing a parameter <code>e</code> to functions that handle JavaScript events, such as the code block below:</p>
  
  <pre><code>function myEvent(e) {
      var evtType = e.type
      alert(evtType)
      // displays click, or whatever the event type was
  }
  </code></pre>
  
  <p>I've always accepted that as being the way it is, but now I have some questions (this is very confusing to me):</p>
  
  <ol>
  <li>Where does this <code>e</code> come from? When I look at the entire JavaScript file, <code>e</code> does not seem to exist at all. </li>
  <li>Why pass this parameter <code>e</code> to functions? Will functions stop working if I do not pass <code>e</code> to them?</li>
  <li><p>Consider the code block below. There is an event variable (<code>e</code>) passed to an anonymous inner function. Let's say I want to use an event object outside of the anonymous function (maybe in a line above/below the <code>element.onkeypress</code> line). How can I do this?</p>
  
  <pre><code>element.onkeypress = function(e) {
      if(e.keyCode) {
          element.keyCode = e.keyCode;
      } else {
          element.keyCode = e.charCode;
      }
  };
  </code></pre></li>
  </ol>