mwg API
    Preparing search index...

    Type Alias Action

    Action: string

    Keyboard input, bound to named actions.

    Game code asks about 'confirm', never about 'Enter'. That indirection is what makes rebinding possible at all, and it is far easier to put in from the start than to retrofit once a hundred call sites know about key codes.

    Keys are identified by KeyboardEvent.code (the physical key), so a binding to KeyZ lands on the same place under AZERTY as under QWERTY, which is what a player actually wants from a movement key.

    import { Input } from '@datamoc/mw_games/core';

    Input.bind('confirm', ['Enter', 'Space']);
    Input.bind('left', ['ArrowLeft', 'KeyA']);

    // in the game loop:
    if (Input.justPressed('confirm')) console.log('confirmed');
    if (Input.isDown('left')) console.log('moving left');