{"id":17677586,"url":"https://github.com/sleitnick/rbxts-clack","last_synced_at":"2026-01-29T03:11:46.036Z","repository":{"id":57683511,"uuid":"488751569","full_name":"Sleitnick/rbxts-clack","owner":"Sleitnick","description":"User input helper classes","archived":false,"fork":false,"pushed_at":"2024-02-08T23:51:55.000Z","size":140,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-22T23:48:08.319Z","etag":null,"topics":["roblox-ts"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@rbxts/clack","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/Sleitnick.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-04T21:44:34.000Z","updated_at":"2024-09-30T11:56:02.000Z","dependencies_parsed_at":"2024-10-24T12:13:43.752Z","dependency_job_id":null,"html_url":"https://github.com/Sleitnick/rbxts-clack","commit_stats":{"total_commits":17,"total_committers":1,"mean_commits":17.0,"dds":0.0,"last_synced_commit":"d19c72c76d89726bb08e7740da4c879031c4c3f2"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sleitnick%2Frbxts-clack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sleitnick%2Frbxts-clack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sleitnick%2Frbxts-clack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sleitnick%2Frbxts-clack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sleitnick","download_url":"https://codeload.github.com/Sleitnick/rbxts-clack/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253996228,"owners_count":21996677,"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":["roblox-ts"],"created_at":"2024-10-24T07:29:04.922Z","updated_at":"2026-01-29T03:11:45.977Z","avatar_url":"https://github.com/Sleitnick.png","language":"TypeScript","readme":"# Clack\n\nUser input helper classes.\n\n## Examples\n\nBelow are examples of the input classes. The examples are not an exhaustive list of the APIs available.\n\n### Preferred Input\n\nThe preferred input is based on the last input the user has made. Because players can change their desired input during gameplay, it is helpful to watch for these changes in order to help direct the player in the best way possible.\n\nFor instance, if there are UI elements that show the player the control schema for the game, using `observePreferredInput` can be used to dynamically change this display if the user switches between using a gamepad and using a mouse/keyboard.\n\n```ts\nconst prefer = new Prefer();\n\nprint(`Preferred: ${tostring(prefer.getPreferredInput())}`);\n\nprefer.observePreferredInput((preferred) =\u003e {\n\tprint(`Preferred: ${tostring(preferred)}`);\n\tif (preferred === Clack.InputType.MouseKeyboard) {\n\t\tprint(\"Prefer mouse and keyboard\");\n\t} else if (preferred === Clack.InputType.Touch) {\n\t\tprint(\"Prefer touch\");\n\t} else if (preferred === Clack.InputType.Gamepad) {\n\t\tprint(\"Prefer gamepad\");\n\t}\n});\n```\n\n### Mouse\n\nWatch for mouse input.\n\n```ts\nconst mouse = new Mouse();\n\nmouse.getButtonDownSignal(Enum.UserInputType.MouseButton1).Connect((position) =\u003e {\n\tprint(\"Left button down\", position);\n});\n\nprint(mouse.getPosition());\n\nconst result = mouse.raycast(new RaycastParams());\n```\n\n### Keyboard\n\nWatch for keyboard input.\n\n```ts\nconst keyboard = new Keyboard();\n\nkeyboard.keyDown.Connect((keyCode) =\u003e {\n\tprint(`Key down: ${tostring(keyCode)}`);\n});\n\nkeyboard.keyUp.Connect((keyCode) =\u003e {\n\tprint(`Key up: ${tostring(keyCode)}`);\n});\n\nprint(\"W down\", keyboard.isKeyDown(Enum.KeyCode.W));\n\nprint(\"CTRL+S\", keyboard.isKeyComboDown(Enum.KeyCode.LeftControl, Enum.KeyCode.S));\n\nprint(\"Forward\", keyboard.isEitherKeyDown(Enum.KeyCode.W, Enum.KeyCode.Up));\n```\n\n### Gamepad\n\nWatch for gamepad input.\n\n```ts\nconst gamepad = new Gamepad();\n\ngamepad.buttonDown.Connect((button) =\u003e {\n\tprint(`Button down: ${tostring(button)}`);\n});\n\ngamepad.setMotor(Enum.VibrationMotor.Large, 1);\ngamepad.stopMotor(Enum.VibrationMotor.Large);\ngamepad.pulseMotor(Enum.VibrationMotor.Large, 1, 0.2);\n\nconst leftThumbstickPos = gamepad.getThumbstick(Enum.KeyCode.Thumbstick1);\nprint(`Left thumbstick position: ${tostring(leftThumbstickPos)}`);\n```\n\n### Touch\n\nWatch for touch input.\n\n```ts\nconst touch = new Touch();\n\ntouch.getTouchTapSignal().Connect((touchPositions, processed) =\u003e {\n\tprint(\"Touched\");\n});\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsleitnick%2Frbxts-clack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsleitnick%2Frbxts-clack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsleitnick%2Frbxts-clack/lists"}