Socket
Socket
Sign inDemoInstall

@arcade2d/controls

Package Overview
Dependencies
1
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @arcade2d/controls

Game control input library.


Version published
Weekly downloads
3
increased by200%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Controls

Input detection components for browser-based game controls.

Installation

$ yarn add @arcade2d/controls

Examples

Keyboard Input

import {
  KeyboardInput,
  KeyboardInputEvent,
  KeyboardState,
} from '@arcade2d/controls';

// Define keyboard input manager instance.
const keyboard = new KeyboardInput(document);

// Handle key press and release handlers.
keyboard.onKeyPress((event: KeyboardInputEvent) =>
  console.log('press', event.key),
);
keyboard.onKeyRelease((event: KeyboardInputEvent) =>
  console.log('release', event.key),
);

// Check keyboard state during a loop.
setInterval(() => {
  const state: KeyboardState = keyboard.getState();

  if (state.isDown('a')) {
    console.log('a is held down');
  }
}, 16);

FAQs

Last updated on 06 Jun 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc