Javascript ActiveElement and Keydown Event Listener
<p>I'm new to Javascript and I'm trying to make the following code scan to see if a textbox with an id="lessonNum" is active, if it is not i would like to send a .click to a submit button with an id="A" when I press 'a' on the keyboard. Right now when I select the textbox I get an alert, but when I don't have it selected it doesn't pick up my keydown. Please Help!</p>

<pre><code>function GetActive () {

    if (document.activeElement.id == 'lessonNum') {
        alert('lessonNum is active');
        var b1=new Boolean(1);

    } else {
       var b1=new Boolean(0);
    }
}

document.addEventListener("keydown", keyDownTextField, false);

function keyDownTextField(e) {
    var keyCode = e.keyCode;

    if(keyCode==65) {

        if(b1==0) {
            alert('a has been pressed');
            document.getElementById('A').click();
        } 
    }
}
</code></pre>
