MCPcopy
hub / github.com/KilledByAPixel/LittleJS / keyIsDown

Function keyIsDown

src/engineInput.js:104–109  ·  view source on GitHub ↗

Returns true if device key is down * @param {string|number} key * @param {number} [device] * @return {boolean} * @memberof Input

(key, device=0)

Source from the content-addressed store, hash-verified

102 * @return {boolean}
103 * @memberof Input */
104function keyIsDown(key, device=0)
105{
106 ASSERT(isStringLike(key), 'key must be a number or string');
107 ASSERT(device > 0 || typeof key !== 'number' || key < 3, 'use code string for keyboard');
108 return !!(inputData[device]?.[key] & 1);
109}
110
111/** Returns true if device key was pressed this frame
112 * @param {string|number} key

Callers 10

kFunction · 0.85
mouseIsDownFunction · 0.85
gamepadIsDownFunction · 0.85
debugRenderFunction · 0.85
engineUpdateFunction · 0.85
gameUpdateFunction · 0.85
updateMethod · 0.85
updateMethod · 0.85

Calls 2

isStringLikeFunction · 0.85
ASSERTFunction · 0.70

Tested by

no test coverage detected