Onkeypress函数返回空格而不是字母
我正在使用以下命令并试图使用户的字母猜测出现在屏幕上,但是当我检查devtools时,按键将返回到[[,,,,,]等数组。没有字母有想法吗?
var letguessText = document.getElementById(“ letguess”)
var猜测数组= []
document.onkeypress= function(event){
var guess = event.key
guessArray.push(String.fromCharCode(guess))...