Create a Keyboard bound to window (or a custom target).
window
Returns a no-op stub when called in a non-browser environment so that isomorphic game code doesn't crash on the server — isDown will always be false and listeners will never fire.
isDown
false
const kb = createKeyboard();kb.onDown('ArrowRight', () => player.move(5, 0));kb.onDown('Escape', () => game.stop());// In your loop:if (kb.isDown(' ')) player.charge(); Copy
const kb = createKeyboard();kb.onDown('ArrowRight', () => player.move(5, 0));kb.onDown('Escape', () => game.stop());// In your loop:if (kb.isDown(' ')) player.charge();
Create a Keyboard bound to
window(or a custom target).Returns a no-op stub when called in a non-browser environment so that isomorphic game code doesn't crash on the server —
isDownwill always befalseand listeners will never fire.