How to assign event to variable in JS
<p>Hello I have a pretty basic question about events in JS.</p>

<p>Can I do something like:</p>

<pre><code>var myobj = { };
document.getElementById("myid").onmousemove = function (e) {
  myobj.e = e;
}

...

// called from function which will occure after onmousemove guaranteed
document.getElementById("info").innerHTML = myobj.e.type;
</code></pre>

<p>I need this for my game. I want to save event data and dispatch it later in update function of my game loop.</p>

<p>Okay. Here is jsfiddle.</p>

<pre><code>&lt;p id="info"&gt;&lt;/p&gt;&lt;canvas id="can" width="400px" height="400px" style="border: 2px solid red"&gt;&lt;/canvas&gt;

var my = { };
document.getElementById("can").onclick = function(e, custom) {
    my.e = e;
}
document.getElementById("can").onmouseover = function(e, custom) {
    my.e = e;
}
document.getElementById("can").onmouseout = function(e, custom) {
    my.e = e;
}
document.getElementById("can").oncontextmenu = function(e, custom) {
    my.e = e;
}
document.getElementById("info").innerHTML = my.e.type;
</code></pre>

<p><a href="http://jsfiddle.net/cMPSS/3/" rel="nofollow">http://jsfiddle.net/cMPSS/3/</a></p>

<p>And it doesnt work.</p>
