在页面上 获取键盘事件
2020-08-24 本文已影响0人
小白的踩坑日常
在页面上 获取键盘事件
需要用原生才行, jquery无效
function showkey(event){
asc = event.keyCode;
key = String.fromCharCode(asc);
str += key;
console.log(str)
}
document.onkeypress=showkey;
需要用原生才行, jquery无效
function showkey(event){
asc = event.keyCode;
key = String.fromCharCode(asc);
str += key;
console.log(str)
}
document.onkeypress=showkey;