A keyboard/gamepad binder for easier game input in TypeScript and JavaScript
TypeScript JavaScript HTML
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.


Build Status


KeyActionBinder aims to provide universal game input control for both keyboard and game controllers in JavaScript. It works independently of the game engine, the browser, or the hardware platform it is running in.


  • Having a clear, easy to use interface.
  • Minimizing the amount of support logic needed in a game loop.
  • Providing support for typical game functionality such as button press time tolerance, dead zone protection, and others.
  • Requiring no device or control references to store.
  • Working around browser limitations where appropriate (and possible).
  • Self-containment and independence from any other system, framework, or game engine.
  • Auto-management of gamepad order for sensible party/multi-player support.

Quick usage

Include one of the build files:

<script src="key-action-binder.min.js"></script>

Create a KeyActionBinder instance:

var binder = new KeyActionBinder();

Setup actions with as many bindings as you want:




Then, evaluate the actions inside your game loop:

function myGameLoop() {
	// Check whether the player should move
	if (binder.action("move-left").activated) {
		// (...code for moving left...)
	} else if (binder.action("move-right").activated) {
		// (...code for moving right...)

	if (playerIsOnGround && binder.action("jump").activated) {
		// (...code for performing jump...)

Read more about the project in the wiki.