like2d
    Preparing search index...

    Interface Keyboard

    A basic wrapper around keyboard.

    Keyboard uses scancodes by default, which are based on physical key positions rather than the logical (letter) meaning of the key.

    Using keyboard directly is discouraged, but of course allowed. Take a look at the actions system in input for a better solution.

    Also where there's text input such as enter your name, use the key code. This allows the user to use their intended keyboard layout.

    like.keypressed = (_code, key) => {
    name += key;
    }

    Even if your game is heavily keyboard-reliant (like nethack), it is best to avoid mapping directly. Referring to action drink instead of code KeyD is also more programmer-ergonomic.

    interface Keyboard {
        isAnyDown(...scancodes: string[]): boolean;
        isDown(scancode: string): boolean;
    }
    Index

    Methods

    • Parameters

      • ...scancodes: string[]

      Returns boolean

    • Parameters

      • scancode: string

      Returns boolean