{"id":15661086,"url":"https://github.com/tentone/syncinput","last_synced_at":"2025-07-14T02:32:50.803Z","repository":{"id":65480169,"uuid":"69164580","full_name":"tentone/syncinput","owner":"tentone","description":"Synchronous keyboard and mouse input for web applications. Useful for games and canvas / webgl synchronous content in web applications.","archived":false,"fork":false,"pushed_at":"2024-09-03T22:38:27.000Z","size":9744,"stargazers_count":22,"open_issues_count":2,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-18T23:47:37.715Z","etag":null,"topics":["canvas","game-controller","gamepads","synchronous","web-game-dev","webgl"],"latest_commit_sha":null,"homepage":"https://tentone.github.io/syncinput/","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/tentone.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-25T13:01:55.000Z","updated_at":"2025-03-15T03:14:51.000Z","dependencies_parsed_at":"2024-08-27T17:19:57.995Z","dependency_job_id":"da678076-5137-4bd3-936a-d1f0f7f909c5","html_url":"https://github.com/tentone/syncinput","commit_stats":{"total_commits":70,"total_committers":1,"mean_commits":70.0,"dds":0.0,"last_synced_commit":"b29191e7e73192bb73a3f6e8a8d63c6fa28e383d"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/tentone/syncinput","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tentone%2Fsyncinput","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tentone%2Fsyncinput/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tentone%2Fsyncinput/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tentone%2Fsyncinput/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tentone","download_url":"https://codeload.github.com/tentone/syncinput/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tentone%2Fsyncinput/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265233753,"owners_count":23731825,"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":["canvas","game-controller","gamepads","synchronous","web-game-dev","webgl"],"created_at":"2024-10-03T13:25:44.185Z","updated_at":"2025-07-14T02:32:50.774Z","avatar_url":"https://github.com/tentone.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"./readme/logo.png\" width=250/\u003e\n\n[![GitHub version](https://badge.fury.io/gh/tentone%2Fsyncinput.svg)](https://badge.fury.io/gh/tentone%2Fsyncinput)[![npm version](https://badge.fury.io/js/syncinput.svg)](https://badge.fury.io/js/syncinput)\n\n- Synchronous keyboard, mouse and gamepad input for fixed step applications.\n- Multi-browser support, compatible with mobile devices and and touchscreen events.\n- Currently supports input from: Mouse, Keyboard, Gamepad, Touchscreen\n- Detailed API docs available on the docs folder of the project.\n- [Demo of the library](https://tentone.github.io/syncinput/demo/) running from the examples directory.\n- [TSDoc](https://tentone.github.io/syncinput/docs/) documentation available.\n\n### Sync Events\n\n- Browser events fire at a different rate than your application logic/render code.\n- This library allow to access input state for variable frame rate scenarios.\n- Skip the need to process out of sync browser callbacks.\n\n\u003cimg src=\"./readme/timing.png\" width=700/\u003e\n\n### Getting Started\n - Get from NPM using ` npm install syncinput --save-prod`\n - Here is a small code example showing the basic functionality of the library.\n\n```javascript\nimport {Keyboard, Keys, Mouse, MouseButton, Touch, Gamepad, GamepadButton} from 'syncinput';\n\n//Initialization\nmouse = new Mouse();\nkeyboard = new Keyboard();\ntouch = new Touch();\ngamepad = new Gamepad();\n\n[...]\n\n//Inside of the logic/rendering loop\nmouse.update();\nkeyboard.update();\n\nconsole.log(\"Position X:\" mouse.position.x + \" Y:\" + mouse.position.y);\nconsole.log(\"Delta X:\" mouse.delta.x + \" Y:\" + mouse.delta.y);\nconsole.log(\"Scroll wheel:\" mouse.wheel);\n\n\nif (touch.touchJustPressed(0)) \n{\n\tconsole.log(\"First touch point just pressed.\");\n}\nif (touch.touchJustReleased(1)) \n{\n\tconsole.log(\"Second touch point just released.\");\n}\n\nif(mouse.buttonPressed(MouseButton.LEFT))\n{\n\tconsole.log(\"Mouse left is pressed\");\n}\n\nif(mouse.buttonPressed(MouseButton.LEFT))\n{\n\tconsole.log(\"Mouse left is pressed\");\n}\n\nif(keyboard.keyPressed(Keys.W) || gamepad.buttonPressed(GamepadButton.UP))\n{\n\tconsole.log(\"W is pressed or Gamepad UP is pressed\");\n}\n\nif(keyboard.keyJustPressed(Keys.W))\n{\n\tconsole.log(\"W was just pressed\");\n}\nif(keyboard.keyJustReleased(Keys.W))\n{\n\tconsole.log(\"W was just released\");\n}\n```\n\n### Mouse\n\n- `position {x, y}` -Actual mouse position\n- `delta {x, y}` - Mouse delta since last time update() was called\n- `wheel` - Mouse wheel value\n\n- `buttonPressed(button)` - Check if mouse button is pressed (touchscreen tap same as left click)\n- `buttonJustPressed(button)` - Check if mouse button was just pressed\n- `buttonJustReleased(button)` - Check if mouse button was just released\n- `setCanvas(canvas)` - Attach canvas to mouse object for position coordinated to be calculated relatively to the canvas.\n- `insideCanvas()` - Check if mouse is inside attached canvas\n- `setLock(value)` - Set mouse lock on/off.\n\n### Keyboard\n\n- `keyPressed(button)` - Check if key is currently pressed\n- `keyJustPressed(button)` - Check if key was just pressed\n- `keyJustReleased(button)` - Check if key was just released\n- `reset()` - Reset all keys\n\n### Touch\n- `points[]` - List of touch points and their respective status.\n- `pan(points)` - Multi-touch pan, retuns the average position and movement delta.\n- `pinchZoom()` - Pinch to zoom (of the first two touch points) delta.\n- `touchPressed(point)` - Check if touch point is pressed\n- `touchJustPressed(point)` - Check if touch point was just pressed\n- `touchJustReleased(point)` - Check if touch point was just released\n\n\n### Gamepad\n[Gamepad input](https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API) is only available in secure context using HTTPS. \n\n- `buttonPressed(button)` - Check if gamepad button is pressed\n- `buttonJustPressed(button)` - Check if gamepad button was just pressed\n- `buttonJustReleased(button)` - Check if gamepad button was just released\n- `getAxis(index)` - Get axial input value from its index from -1 to 1.\n- `getAnalogueButton(index)` - Get analog button from 0 to 1.\n- `getGamepads()` - Get list of available gamepads.\n- `setGamepad(gamepad)` - Set wich gamepad to use.\n\n\u003cimg src=\"./readme/standard.png\" width=400/\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftentone%2Fsyncinput","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftentone%2Fsyncinput","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftentone%2Fsyncinput/lists"}