Returns true if the key it’s checking is pressed and false if not.
keyIsDown() is helpful when checking for multiple different key presses. For example, keyIsDown() can be used to check if both LEFT_ARROW and UP_ARROW are pressed:
if (keyIsDown(LEFT_ARROW) && keyIsDown(UP_ARROW)) {
// Move diagonally.
}
keyIsDown() can check for key presses using keyCode values, as in keyIsDown(37) or keyIsDown(LEFT_ARROW). Key codes can be found on websites such as 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!
관련 레퍼런스
keyCode
A Number system variable that contains the code of the last key typed.
keyIsDown
Returns true if the key it’s checking is pressed and false if not.
keyIsPressed
A Boolean system variable that's true if any key is currently pressed and false if not.
keyPressed
A function that's called once when any key is pressed.