{"id":18779109,"url":"https://github.com/zakaton/tap-strap-web-sdk","last_synced_at":"2025-12-17T21:30:17.815Z","repository":{"id":172558935,"uuid":"649443942","full_name":"zakaton/Tap-Strap-Web-SDK","owner":"zakaton","description":null,"archived":false,"fork":false,"pushed_at":"2023-06-04T21:21:09.000Z","size":15,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-29T10:27:59.869Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zakaton.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2023-06-04T21:19:04.000Z","updated_at":"2024-03-13T18:40:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"9f42becc-7bd1-448e-ad75-1b6196b5e5ba","html_url":"https://github.com/zakaton/Tap-Strap-Web-SDK","commit_stats":null,"previous_names":["zakaton/tap-strap-web-sdk"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zakaton%2FTap-Strap-Web-SDK","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zakaton%2FTap-Strap-Web-SDK/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zakaton%2FTap-Strap-Web-SDK/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zakaton%2FTap-Strap-Web-SDK/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zakaton","download_url":"https://codeload.github.com/zakaton/Tap-Strap-Web-SDK/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239690249,"owners_count":19681066,"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-11-07T20:18:48.351Z","updated_at":"2025-12-17T21:30:17.762Z","avatar_url":"https://github.com/zakaton.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tap Strap Web SDK\n\n_A client-side JavaScript SDK for Tap Strap_\n\n## 📚 Table of Contents\n\n[⚙️ Setting up the SDK](#-setting-up-the-sdk)\n\n[🔓 Setting Input Modes](#-setting-input-modes)\n\n[💥 Setting Sensitivity](#-setting-sensitivity)\n\n[👂 Listening for Events](#-listening-for-events)\n\n[📳 Vibration](#-vibration)\n\n[🔋 Getting Battery Level](#-getting-battery-level)\n\n## ⚙️ Setting up the SDK\n\n0. Make sure you have a Web Bluetooth-enabled device\n   - **Chrome for Desktop [PREFERRED]**: enable Web Bluetooth by going to `chrome://flags/#enable-experimental-web-platform-features` and check `Experimental Web Platform features`\n   - **iOS**: Use [WebBLE](https://itunes.apple.com/us/app/webble/id1193531073?mt=8) or [Blufy](https://apps.apple.com/us/app/bluefy-web-ble-browser/id1492822055) to demo your web apps. Unfortunately iOS is [very negligent](https://github.com/WebBluetoothCG/web-bluetooth/blob/master/implementation-status.md) on various Web API's.\n\n1. Download the [Tap Manager App](https://www.tapwithus.com/apps/) and connect to your Tap Strap. There you can update the firmware to the latest version, and enable \"Developer Mode\"\n\n2. Save a copy of the [Web SDK](https://tap-strap-web-sdk.glitch.me/TapStrap.js)\n\n3. In your HTML `\u003chead\u003e\u003c/head\u003e` element, insert the file in a script element, along with [Three.js](https://threejs.org/):\n\n```html\n\u003cscript src=\"https://cdnjs.cloudflare.com/ajax/libs/three.js/r118/three.min.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"TapStrap.js\"\u003e\u003c/script\u003e\n```\n\nThis will create global `TapStrap` class\n\n4. Create a `TapStrap` instance:\n\n```javascript\nconst tapStrap = new TapStrap();\n```\n\n5. Connect to the tap strap using the `tapStrap.connect()` method, which returns a `Promise`:\n\n```javascript\ntapStrap.connect().then(() =\u003e {\n  console.log(\"connected to the tap strap!\");\n});\n```\n\nYou can also add an eventlistener for the `\"connect\"` event:\n\n```javascript\ntapStrap.addEventListener(\"connect\", (event) =\u003e {\n  console.log(\"triggered the 'connect' event\");\n});\n\ntapStrap.connect();\n```\n\n## 🔓 Setting Input Mode\n\n```javascript\n// \"raw\" dispatches sensor data\ntapStrap.inputMode = \"raw\";\n\n// \"controller\" and \"controllerText\" dispatches tap and mouse data\ntapStrap.inputMode = \"controller\";\n```\n\n## 💥 Setting Sensitivity\n\n```javascript\ntapStrap.sensitivity = [0, 0, 0];\n```\n\n## 👂 Listening for Events\n\n```javascript\n\n// Tap Data\ntapStrap.addEventListener(\"tapdata\", event =\u003e {\n  const { message } = event;\n  const { tapData, timeInterval } = message;\n\n  // finger names are [\"thumb\", \"pointer\", \"middle\", \"ring\", \"pinky\"]\n  for (const fingerName in tapData) {\n    const didTap = tapData[fingerName];\n    console.log(`the ${fingerName} finger ${didTap? \"did\":\"did not\"} tap`);\n  }\n}\n\n// Mouse Data\ntapStrap.addEventListener(\"mouse\", event =\u003e {\n  const { message } = event;\n  const { x, y, proximation } = message;\n  // proximation is whether the hand is on a surface or in the air (Tap Strap 2 only)\n  console.log(`mouse movement: (${x}, ${y}`);\n});\n\n// Air Gestures\ntapStrap.addEventListener(\"airgesture\", event =\u003e {\n  const { message } = event;\n  const { airGesture } = message;\n  console.log(\"air gesture\", airGesture);\n});\n\n// Raw Data\ntapStrap.addEventListener(\"raw\", event =\u003e {\n  const { message } = event;\n  const { messages } = message;\n  messages.forEach(({ type, timestamp, sensors }) =\u003e {\n    switch (type) {\n      case \"accelerometer\":\n        console.log(\"accelerometer\", sensors)\n        break;\n\n      // Thumb IMU data (Tap Strap 2 only)\n      case \"imu\":\n        const gyroscope = sensors[0];\n        const accelerometer = sensors[1];\n        console.log(\"IMU gyroscope\", gyroscope);\n        console.log(\"IMU accelerometer\", accelerometer);\n        break;\n    }\n  });\n});\n```\n\n## 📳 Vibration\n\n```javascript\n// pass a sequence of (vibration duration, delay) values in milliseconds\ntapStrap.vibrate([1000, 300, 200]);\n// vibrates for 1s, delays for 300ms, then vibrates for 200ms\n```\n\n## 🔋 Getting Battery Level\n\n```javascript\n// returns a promise containing the battery level as a value between 0 to 100\ntapStrap.getBatteryLevel().then((batteryLevel) =\u003e {\n  console.log(\"Battery Level is now\", batteryLevel);\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzakaton%2Ftap-strap-web-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzakaton%2Ftap-strap-web-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzakaton%2Ftap-strap-web-sdk/lists"}