gameplate - v2.2.0
    Preparing search index...

    Function createKeyboard

    • 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 — isDown will always be false and listeners will never fire.

      Parameters

      • options: KeyboardOptions = {}

      Returns Keyboard

      const kb = createKeyboard();
      kb.onDown('ArrowRight', () => player.move(5, 0));
      kb.onDown('Escape', () => game.stop());
      // In your loop:
      if (kb.isDown(' ')) player.charge();