isKeyDown(k?: Key | Key[]): boolean
If any or certain key(s) are currently down.// Any key down let lastKeyTime = time() let triedToWakeUp = false onUpdate(() => { if (isKeyDown()) { lastKeyTime = time() triedToWakeUp = false return } if (triedToWakeUp || time() - lastKeyTime < 5) return debug.log("Wake up!") triedToWakeUp = true }) // Certain key down // equivalent to the calling bean.move() in an onKeyDown("left") onUpdate(() => { if (isKeyDown("left")) { bean.move(-SPEED, 0) } }) // Certain keys down let isMoving = false onUpdate(() => { isMoving = isKeyDown(["left", "right"]) })
since