Returns input vector from arrow keys or WASD if enabled * @param {string} [up] * @param {string} [down] * @param {string} [left] * @param {string} [right] * @return {Vector2} * @memberof Input
(up='ArrowUp', down='ArrowDown', left='ArrowLeft', right='ArrowRight')
| 140 | * @return {Vector2} |
| 141 | * @memberof Input */ |
| 142 | function keyDirection(up='ArrowUp', down='ArrowDown', left='ArrowLeft', right='ArrowRight') |
| 143 | { |
| 144 | ASSERT(isStringLike(up), 'up key must be a string'); |
| 145 | ASSERT(isStringLike(down), 'down key must be a string'); |
| 146 | ASSERT(isStringLike(left), 'left key must be a string'); |
| 147 | ASSERT(isStringLike(right), 'right key must be a string'); |
| 148 | const k = (key)=> keyIsDown(key) ? 1 : 0; |
| 149 | return vec2(k(right) - k(left), k(up) - k(down)); |
| 150 | } |
| 151 | |
| 152 | /** Returns true if mouse button is down |
| 153 | * @function |
no test coverage detected