1.1.1 • Published 5 months ago

@hydroperx/inputaction v1.1.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
5 months ago

Input action

Input action library for web applications.

This library allows managing and handling keyboard actions such as shortcuts. It may support gamepads in the future.

Features:

  • Reflect actions
  • Shortcut display text
  • Pooling of pressed keys

Getting started

import { input } from "@hydroperx/inputaction";

input.setActions({
    "moveLeft": [
        { key: "a" },
        { key: "leftArrow" },
    ],
    "moveRight": [
        { key: "d" },
        { key: "rightArrow" },
    ],
    "moveUp": [
        { key: "w" },
        { key: "upArrow" },
    ],
    "moveDown": [
        { key: "s" },
        { key: "downArrow" },
    ],
});

input.on("inputPressed", () => {
    // use isPressed() or justPressed()
    const shouldMoveRight = input.justPressed("moveRight");
});
1.1.1

5 months ago

1.1.0

5 months ago

1.0.3

6 months ago

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago