On hitting a key in a textbox I want it converted to UpperCase.
Code JavaScript:
        document.getElementById("txt1").onkeypress = function(e)
                var e = e || window.event;
                var k = e.which || e.keyCode;
                k = String.fromCharCode(k).toUpperCase().charCodeAt(0);
This obviously doesnt work because the function is called after the key is pressed and k doest reference the key in the textbox.

Is there a way ?