{"id":13744397,"url":"https://github.com/zeh/key-action-binder","last_synced_at":"2025-05-09T03:31:30.980Z","repository":{"id":30625936,"uuid":"34181372","full_name":"zeh/key-action-binder","owner":"zeh","description":"A keyboard/gamepad binder for easier game input in TypeScript and JavaScript","archived":true,"fork":false,"pushed_at":"2015-09-27T20:57:18.000Z","size":464,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-26T16:46:58.097Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zeh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-18T20:23:05.000Z","updated_at":"2023-01-28T12:40:38.000Z","dependencies_parsed_at":"2022-08-29T10:50:49.138Z","dependency_job_id":null,"html_url":"https://github.com/zeh/key-action-binder","commit_stats":null,"previous_names":["zeh/key-action-binder.ts"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeh%2Fkey-action-binder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeh%2Fkey-action-binder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeh%2Fkey-action-binder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeh%2Fkey-action-binder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zeh","download_url":"https://codeload.github.com/zeh/key-action-binder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253183127,"owners_count":21867366,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T05:01:08.625Z","updated_at":"2025-05-09T03:31:30.722Z","avatar_url":"https://github.com/zeh.png","language":"TypeScript","funding_links":[],"categories":["Video Games"],"sub_categories":["Game Engine"],"readme":"[![Build Status](https://travis-ci.org/zeh/key-action-binder.ts.svg?branch=master)](https://travis-ci.org/zeh/key-action-binder.ts)\n\n# KeyActionBinder\n\nKeyActionBinder 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.\n\n\n## Goals\n\n * Having a clear, easy to use interface.\n * Minimizing the amount of support logic needed in a game loop.\n * Providing support for typical game functionality such as button press time tolerance, dead zone protection, and others.\n * Requiring no device or control references to store.\n * Working around browser limitations where appropriate (and possible).\n * Self-containment and independence from any other system, framework, or game engine.\n * Auto-management of gamepad order for sensible party/multi-player support.\n\n\n## Quick usage\n\nInclude one of the [build files](https://github.com/zeh/key-action-binder.ts/tree/master/build):\n\n\t\u003cscript src=\"key-action-binder.min.js\"\u003e\u003c/script\u003e\n\nCreate a `KeyActionBinder` instance:\n\n\tvar binder = new KeyActionBinder();\n\nSetup actions with as many bindings as you want:\n\n\tbinder.action(\"move-left\")\n\t\t.bind(KeyActionBinder.KeyCodes.LEFT)\n\t\t.bind(KeyActionBinder.GamepadButtons.DPAD_LEFT);\n\n\tbinder.action(\"move-right\")\n\t\t.bind(KeyActionBinder.KeyCodes.RIGHT)\n\t\t.bind(KeyActionBinder.GamepadButtons.DPAD_RIGHT);\n\n\tbinder.action(\"jump\")\n\t\t.bind(KeyActionBinder.KeyCodes.SPACE)\n\t\t.bind(KeyActionBinder.GamepadButtons.ACTION_DOWN);\n\nThen, evaluate the actions inside your game loop:\n\n\tfunction myGameLoop() {\n\t\t// Check whether the player should move\n\t\tif (binder.action(\"move-left\").activated) {\n\t\t\t// (...code for moving left...)\n\t\t} else if (binder.action(\"move-right\").activated) {\n\t\t\t// (...code for moving right...)\n\t\t}\n\n\t\tif (playerIsOnGround \u0026\u0026 binder.action(\"jump\").activated) {\n\t\t\t// (...code for performing jump...)\n\t\t}\n\t}\n\nRead more about the project in the [wiki](https://github.com/zeh/key-action-binder.ts/wiki).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeh%2Fkey-action-binder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzeh%2Fkey-action-binder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeh%2Fkey-action-binder/lists"}