需要用原生才行, jquery无效

 

function showkey(event){
asc = event.keyCode;
key = String.fromCharCode(asc);
str += key;

console.log(str)
}

 document.onkeypress=showkey;