JavaScript: Why onKeyDown and onKeyUp don't work while onFocus is working in this code
<pre><code>function PrepareCounter() {
    var ct = 1;
    while(document.getElementById("id_answer"+ct)) {
        document.getElementById("id_answer"+ct).setAttribute("onFocus", "countChars('textbox','char_count',140)", "onKeyDown", "countChars('textbox','char_count',140)", "onKeyUp", "countChars('textbox','char_count',140)");
        ct += 1;
    }
}
</code></pre>

<p>If i focus my element <code>countChars</code> is executed but if i write something it's not.</p>
