Skip to main content
Home
It is unknown whether this package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
It is unknown whether this package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score
52%
Published
9 months ago (1.0.6)

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 "@hydroper/inputaction";

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

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

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@hydroper/inputaction

Import symbol

import * as inputaction from "@hydroper/inputaction";
or

Import directly with a jsr specifier

import * as inputaction from "jsr:@hydroper/inputaction";

Add Package

pnpm i jsr:@hydroper/inputaction
or (using pnpm 10.8 or older)
pnpm dlx jsr add @hydroper/inputaction

Import symbol

import * as inputaction from "@hydroper/inputaction";

Add Package

yarn add jsr:@hydroper/inputaction
or (using Yarn 4.8 or older)
yarn dlx jsr add @hydroper/inputaction

Import symbol

import * as inputaction from "@hydroper/inputaction";

Add Package

vlt install jsr:@hydroper/inputaction

Import symbol

import * as inputaction from "@hydroper/inputaction";

Add Package

npx jsr add @hydroper/inputaction

Import symbol

import * as inputaction from "@hydroper/inputaction";

Add Package

bunx jsr add @hydroper/inputaction

Import symbol

import * as inputaction from "@hydroper/inputaction";