Keyboard Listening

Press any keys:

This should work across the major browsers and in a W3C-compliant way.

function keyListen(e) { var strKey = e.which; if (strKey == undefined) strKey = e.keyCode; document.getElementById("tstTxt").innerHTML += String.fromCharCode(strKey); } function addEvent(obj, evType, fn) { if (obj.addEventListener) {obj.addEventListener(evType, fn, false);} else if (obj.attachEvent) {obj.attachEvent("on"+evType, fn);} else {obj["on" + evType] = fn} } function assignEvents() { addEvent(document.getElementsByTagName("html")[0], "mousemove", mouseTrac) }