addEventListener fails inside of function
<p>I'm having trouble adding an event listener. I'm basically encapsulating all keyboard-related functions into a JavaScript class like so:</p>

<pre><code>function Keyboard()
{
    this.key = new Array();

    for(x=0;x&lt;255;x++)
    {
        this.key[x] = false;
    }

    function keyDown(evt)
    {
        this.key[evt.keyCode] = true;
        console.log("Keydown bioch");
    }

    function keyUp(evt)
    {
        this.key[evt.keyCode] = false;
    }

    window.addEventListener('keydown', this.keyDown, true);
    window.addEventListener('keyup', this.keyUp, true);
}
</code></pre>

<p>Except that it doesn't work - at all. When I remove the Keyboard function and make everything global (key[], keyDown, keyUp, and addEventListener calls), everything works.</p>

<p>What am I doing wrong?</p>
