如果正在检查的键被按下,则返回 true,否则返回 false。
keyIsDown() 在检查多个不同键按下时很有帮助。例如,keyIsDown() 可用于检查是否同时按下了 LEFT_ARROW 和 UP_ARROW:
if (keyIsDown(LEFT_ARROW) && keyIsDown(UP_ARROW)) {
// Move diagonally.
} keyIsDown() 可以使用 keyCode 值检查按键,如 keyIsDown(37) 或 keyIsDown(LEFT_ARROW)。键码可以在如 keycode.info 等网站上找到。
示例
语法
keyIsDown(code)
参数
code
Number:
key to check.
返回值
Boolean: whether the key is down or not.
This page is generated from the comments in src/events/keyboard.js . Please feel free to edit it and submit a pull request!