{"id":26924499,"url":"https://github.com/yukiniro/toukey","last_synced_at":"2025-04-02T01:54:20.162Z","repository":{"id":38745915,"uuid":"461239833","full_name":"Yukiniro/toukey","owner":"Yukiniro","description":"👻 Toukey is a simple and efficient keyboard events library.","archived":false,"fork":false,"pushed_at":"2025-03-24T13:43:55.000Z","size":1676,"stargazers_count":3,"open_issues_count":11,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T03:35:08.432Z","etag":null,"topics":["events","hotkey","javascript","keyboard","keyboardevent","keydown","keyup","shortcuts","toukey"],"latest_commit_sha":null,"homepage":"toukey.vercel.app","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/Yukiniro.png","metadata":{"files":{"readme":"README-zh.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-19T15:58:23.000Z","updated_at":"2024-01-12T18:27:27.000Z","dependencies_parsed_at":"2023-02-18T09:45:46.312Z","dependency_job_id":"6b697e60-0767-42c8-b905-e1b3a7f3d37a","html_url":"https://github.com/Yukiniro/toukey","commit_stats":{"total_commits":132,"total_committers":2,"mean_commits":66.0,"dds":0.3484848484848485,"last_synced_commit":"9863bd4a618c19ab17deab949d7bc8b388feb51d"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yukiniro%2Ftoukey","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yukiniro%2Ftoukey/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yukiniro%2Ftoukey/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yukiniro%2Ftoukey/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Yukiniro","download_url":"https://codeload.github.com/Yukiniro/toukey/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246741107,"owners_count":20826064,"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":["events","hotkey","javascript","keyboard","keyboardevent","keydown","keyup","shortcuts","toukey"],"created_at":"2025-04-02T01:54:19.712Z","updated_at":"2025-04-02T01:54:20.155Z","avatar_url":"https://github.com/Yukiniro.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Toukey\n\n`Toukey` 是一个简单、高效的键盘事件库。这里是 [toukey](https://toukey.vercel.app/) 的文档网站 [toukey's]。\n\n## 安装\n\n```shell\nnpm i toukey\n```\n\n## 使用\n\n### 浏览器\n\n你可以在浏览器中通过 [UNPKG](https://unpkg.com/browse/toukey/dist/) | [jsDelivr](https://www.jsdelivr.com/package/npm/toukey) 这些 `cdn` 进行使用。\n\n```javascript\n\u003cscript src=\"https://unpkg.com/toukey/dist/toukey.umd.min.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  toukey.subscribe('space', function() {\n    console.log('space');\n  });\n\u003c/script\u003e\n```\n\n### React\n\n在 react 也很容易。\n\n```javascript\nimport { useEffect } from \"react\";\nimport { subscribe } from \"toukey\";\n\nfunction App() {\n  useEffect(() =\u003e {\n    return subscribe(\"scope\", () =\u003e {\n      console.log(\"scope\");\n    });\n  });\n\n  return \u003cdiv\u003ehello world\u003c/div\u003e;\n}\n```\n\n这里有一个基于 `toukey` 制作的 react hook 的库 [react-toukey-hook](https://github.com/Yukiniro/react-toukey-hook)。\n\n### 基本使用\n\n```javascript\nimport * as Toukey from \"toukey\";\n\nconst handler = () =\u003e console.log(\"handler\");\n\n// subscribe\nToukey.on(\"scope\", handler);\n\n// unsubscribe\nToukey.off(\"scope\", handler);\n```\n\n```javascript\nimport { subscribe } from \"toukey\";\n\nconst unsubsribe = subscribe(\"scope\", () =\u003e {\n  console.log(\"scope\");\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyukiniro%2Ftoukey","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyukiniro%2Ftoukey","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyukiniro%2Ftoukey/lists"}