{"id":19146750,"url":"https://github.com/lcluber/krait.js","last_synced_at":"2026-06-12T10:30:18.928Z","repository":{"id":24270491,"uuid":"101069565","full_name":"LCluber/Krait.js","owner":"LCluber","description":"Key binding library with multiple keystroke detection","archived":false,"fork":false,"pushed_at":"2022-12-06T22:14:44.000Z","size":4775,"stargazers_count":2,"open_issues_count":19,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-03T18:55:33.222Z","etag":null,"topics":["javascript","key-binding","typescript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/LCluber.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-22T14:05:06.000Z","updated_at":"2024-08-12T19:32:07.000Z","dependencies_parsed_at":"2023-01-14T00:41:04.837Z","dependency_job_id":null,"html_url":"https://github.com/LCluber/Krait.js","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LCluber%2FKrait.js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LCluber%2FKrait.js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LCluber%2FKrait.js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LCluber%2FKrait.js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LCluber","download_url":"https://codeload.github.com/LCluber/Krait.js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240229976,"owners_count":19768597,"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":["javascript","key-binding","typescript"],"created_at":"2024-11-09T07:47:55.013Z","updated_at":"2026-06-12T10:30:18.883Z","avatar_url":"https://github.com/LCluber.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"### This project has been transferred to [DWTechs](https://github.com/DWTechs/CtrlTab.js) and is now called [CtrlTab.js](https://github.com/DWTechs/CtrlTab.js).\r\n\r\n### Please update your project dependencies to [CtrlTab.js](https://github.com/DWTechs/CtrlTab.js) as Krait.js will not be updated anymore.\r\n\r\n---\r\n\r\n## Synopsis\r\n\r\nKrait.js is a key bindings library written in TypeScript with multiple keystroke detection.\r\n\r\n## Motivation\r\n\r\nThe purpose of this library is to provide a simple and easy to use key binding declaration.\r\n\r\n## Installation\r\n\r\n### npm\r\n\r\n```bash\r\n$ npm install @lcluber/kraitjs\r\n```\r\n\r\n### Yarn\r\n\r\n```bash\r\n$ yarn add @lcluber/kraitjs\r\n```\r\n\r\n## Usage\r\n\r\n### ES6\r\n\r\n```javascript\r\nimport { Keyboard } from \"@lcluber/kraitjs\";\r\n\r\nlet keyboard = new Keyboard();\r\n\r\nkeyboard.addCommand(\"group1\", \"action0\", null, [32], action0, {\r\n  preventDefault: true\r\n});\r\nkeyboard.addCommand(\"group1\", \"action1\", { ctrl: true }, [\"G\"], action1, null);\r\n// set another key for action1\r\nkeyboard.setInputs(\r\n  \"group1\",\r\n  \"action1\",\r\n  { ctrl: false, alt: false, shift: false },\r\n  [\"Z\", \"T\"]\r\n);\r\n// Enable group1 commands\r\nkeyboard.watch(\"group1\");\r\n\r\nfunction action0(isKeyDown) {\r\n  if (isKeyDown) {\r\n    // do something;\r\n  }\r\n}\r\n\r\nfunction action1(isKeyDown) {\r\n  if (isKeyDown) {\r\n    // do something;\r\n  }\r\n}\r\n```\r\n\r\n### IIFE\r\n\r\n```javascript\r\nvar keyboard = new Krait.Keyboard();\r\n\r\nkeyboard.addCommand(\"group1\", \"action0\", null, [32], action0, {\r\n  preventDefault: true\r\n});\r\nkeyboard.addCommand(\"group1\", \"action1\", { ctrl: true }, [\"G\"], action1, null);\r\n// set another key for action1\r\nkeyboard.setInputs(\r\n  \"group1\",\r\n  \"action1\",\r\n  { ctrl: false, alt: false, shift: false },\r\n  [\"Z\", \"T\"]\r\n);\r\n// Enable group1 commands\r\nkeyboard.watch(\"group1\");\r\n\r\nfunction action0(isKeyDown) {\r\n  if (isKeyDown) {\r\n    // do something;\r\n  }\r\n}\r\n\r\nfunction action1(isKeyDown) {\r\n  if (isKeyDown) {\r\n    // do something;\r\n  }\r\n}\r\n```\r\n\r\n## API Reference\r\n\r\n```javascript\r\ninterface CtrlKeys {\r\n  ctrl?: boolean;\r\n  alt?: boolean;\r\n  shift?: boolean;\r\n}\r\n\r\ninterface Options {\r\n  preventDefault?: boolean;\r\n  scope?: this;\r\n}\r\n\r\naddCommand(\r\n    name: string,\r\n    ctrlKeys: CtrlKeys | null,\r\n    keys: Array\u003cstring | number\u003e,\r\n    callback: Function,\r\n    options: Options | null\r\n  ): Command {}\r\n\r\nsetInputs(\r\n    ctrlKeys: CtrlKeys,\r\n    keys: Array\u003cstring | number\u003e\r\n  ): boolean {}\r\n\r\nwatch(groupName: string): boolean {} //start watching a group of commands\r\n\r\nignore(groupName: string): boolean {} //stop watching a group of commands\r\n\r\ndefault(groupName: string, commandName: string): boolean {} //set command to default settings\r\n\r\ngetCommand(groupName: string, commandName: string): Command | null {}\r\n\r\n```\r\n\r\n## License\r\n\r\nMIT License\r\n\r\nCopyright (c) 2015 Ludovic CLUBER\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\nSOFTWARE.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flcluber%2Fkrait.js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flcluber%2Fkrait.js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flcluber%2Fkrait.js/lists"}