{"id":13773577,"url":"https://github.com/felixtrz/xrkeys","last_synced_at":"2025-03-18T19:32:15.297Z","repository":{"id":192704342,"uuid":"686870481","full_name":"felixtrz/xrkeys","owner":"felixtrz","description":"Super performant WebXR keyboard","archived":false,"fork":false,"pushed_at":"2023-09-05T00:59:46.000Z","size":17812,"stargazers_count":16,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-02-14T05:35:07.144Z","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/felixtrz.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}},"created_at":"2023-09-04T05:58:56.000Z","updated_at":"2024-02-07T07:50:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"d451cd03-d5a0-4369-b485-448083a8cc28","html_url":"https://github.com/felixtrz/xrkeys","commit_stats":null,"previous_names":["felixtrz/xrkeys"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixtrz%2Fxrkeys","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixtrz%2Fxrkeys/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixtrz%2Fxrkeys/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/felixtrz%2Fxrkeys/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/felixtrz","download_url":"https://codeload.github.com/felixtrz/xrkeys/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244288854,"owners_count":20429088,"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-03T17:01:17.413Z","updated_at":"2025-03-18T19:32:10.287Z","avatar_url":"https://github.com/felixtrz.png","language":"TypeScript","funding_links":[],"categories":["Interaction"],"sub_categories":["XR Interaction"],"readme":"# XRKeys\n\n[![npm version](https://badge.fury.io/js/xrkeys.svg)](https://badge.fury.io/js/xrkeys)\n[![language](https://badgen.net/badge/icon/typescript?icon=typescript\u0026label)](https://www.typescriptlang.org/)\n[![license](https://badgen.net/github/license/felixtrz/xrkeys)](/LICENSE.md)\n\nA highly performant and plug-and-play WebXR keyboard library for Three.js applications. XRKeys empowers your WebXR applications with typing capabilities at the minimal expense of just **two draw calls**, while eliminating the need for extra setup such as loading fonts for the keyboard.\n\n![](example/xrkeys.gif)\n\n## Features\n\n- 🔌 **Plug-and-Play:** No need for extra setup like loading fonts for the keyboard. Just install and use it right away.\n- ⚡️ **High Performance:** Requires only 2 drawcalls, minimal impact on performance of your WebXR applications.\n- 🌍 **Three.js Compatible:** Specifically built for Three.js WebXR applications.\n\n## Demo App\n\nA demo app has been built using Three.js to showcase XRKeys in action. You can check out the demo app at https://felixtrz.github.io/xrkeys/ to see how XRKeys works and to get a feel for its capabilities.\n\nThis demo app is a great resource for developers who are considering using XRKeys in their projects. It provides a hands-on experience with the library and will give you a better understanding of how it works and what it can do.\n\n## Installation\n\nTo install XRKeys, simply run the following command in your terminal:\n\n```sh\n$ npm install xrkeys\n```\n\nOr if you prefer using Yarn:\n\n```sh\n$ yarn add xrkeys\n```\n\n## Usage\n\nUsing XRKeys is simple. First, import the package in your WebXR project:\n\n```js\nimport XRKeys from 'xrkeys';\n```\n\n\u003e **_NOTE:_** NOTE: XRKeys requires Three.js as a peer dependency, make sure to have a recent version installed.\n\nThen, create an instance of the XR keyboard:\n\n```js\nconst keyboard = await XRKeys.create();\n```\n\nThe XRKeys object created extends [THREE.Group](https://threejs.org/docs/#api/en/objects/Group), and can be used as such. Setup the keyboard and add it to your scene:\n\n```js\n// listen for keypress events\nkeyboard.addEventListener('keypress', (e) =\u003e {\n\tconsole.log('Key pressed: ' + e.key);\n});\n\n// you can bind a custom function to the enter key\nkeyboard.onEnter = (text) =\u003e {\n\tconsole.log('Entered text: ' + text);\n};\n\nscene.add(keyboard);\n```\n\nUpdate the keyboard in your render loop:\n\n```js\nfunction render() {\n\t// update the keyboard with a target ray and a pressing flag\n\tconst targetRaySpace = renderer.xr.getController(0);\n\tkeyboard.update(targetRaySpace, triggerIsPressed);\n\n\t// you can also access the keyboard's text content anytime\n\tconsole.log(keyboard.text);\n}\n```\n\n## API Reference\n\n### `XRKeysConfig` type\n\n`XRKeysConfig` is an object type that can have the following optional properties:\n\n- `path?: string`: Path override for custom keyboard model.\n- `keyMaskOffset?: number`: Z Offset for the key mask.\n- `hoverColor?: string`: Color of the key mask when hovered.\n- `pressedColor?: string`: Color of the key mask when pressed.\n\n### `XRKeys` class\n\n`XRKeys` is a class that extends `THREE.Group`.\n\n#### Properties\n\n- `activeKeyboard: THREE.Mesh`: Returns the active keyboard mesh.\n- `activeKeysetIndex: number`: Returns the index of the active keyset.\n- `text: string`: Returns the text inputted using the keyboard.\n- `onEnter: (text: string) =\u003e void`: Callback function called when the Enter key is pressed.\n\n#### Methods\n\n- `static create(config?: XRKeysConfig): Promise\u003cXRKeys\u003e`: Static method that creates and returns a promise that resolves to an `XRKeys` instance. Takes an optional `XRKeysConfig` object as a parameter.\n- `update(targetRaySpace: THREE.Object3D, pressed: boolean): void`: Method to update the keyboard based on the target ray space and whether a key is being pressed.\n\n## License\n\n[MIT License](/LICENSE.md) © 2023 Felix Zhang\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelixtrz%2Fxrkeys","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffelixtrz%2Fxrkeys","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffelixtrz%2Fxrkeys/lists"}