基本上是标题。我需要一个类似于蹲下按钮的功能 - 角色仅在按住向下箭头键时蹲下,而不仅仅是按下一次。我如何使它工作?这是我尝试过但不起作用的方法。提前致谢!!!!!
document.onkeydown = function (event) {
let key = event.key;
while (key == "ArrowDown") {
character.style.width = 50 + "px";
character.style.height = 30 + "px";
character.style.top = 115 + "px";
}
}
Run Code Online (Sandbox Code Playgroud) 假设我的数组是:
const array = [20, 30, 21, 15, 80];
Run Code Online (Sandbox Code Playgroud)
如果我想例如 console.log 它,它将显示以下内容:
20,30,21,15,80
Run Code Online (Sandbox Code Playgroud)
但我希望输出是
20 30 21 15 80
Run Code Online (Sandbox Code Playgroud)
在 console.log 中。
如何使用空格将其分开?我尝试使用 .split 和其他东西,但没有用。提前致谢!!