{"id":30127628,"url":"https://github.com/moeki0/yubi","last_synced_at":"2025-08-10T17:08:48.786Z","repository":{"id":260608818,"uuid":"881824972","full_name":"moeki0/yubi","owner":"moeki0","description":"Yubi is a powerful library for managing keyboard shortcuts with ease and flexibility","archived":false,"fork":false,"pushed_at":"2024-11-02T00:10:54.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-31T13:37:13.544Z","etag":null,"topics":["hotkeys","keyboard","shortcut"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/yubi","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/moeki0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","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,"zenodo":null}},"created_at":"2024-11-01T10:13:18.000Z","updated_at":"2024-11-02T00:11:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"cf0af177-ecf7-4337-a7ca-04cfbdecf695","html_url":"https://github.com/moeki0/yubi","commit_stats":null,"previous_names":["kawakamimoeki/yubi","kawakamidev/yubi","moekiorg/yubi"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/moeki0/yubi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moeki0%2Fyubi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moeki0%2Fyubi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moeki0%2Fyubi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moeki0%2Fyubi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moeki0","download_url":"https://codeload.github.com/moeki0/yubi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moeki0%2Fyubi/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269756394,"owners_count":24470566,"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","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["hotkeys","keyboard","shortcut"],"created_at":"2025-08-10T17:08:43.418Z","updated_at":"2025-08-10T17:08:48.752Z","avatar_url":"https://github.com/moeki0.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Yubi\n\n![v](https://badgen.net/npm/v/yubi)\n![dt](https://badgen.net/npm/dt/yubi)\n![license](https://badgen.net/github/license/kawakamimoeki/yubi)\n\n```typescript\nconst yubi = new Yubi();\ndocument.addEventListener(\"keydown\", (e) =\u003e {\n  yubi.record(e);\n  if (yubi.match(\"cmd+k cmd+t\")) {\n    // Code to be executed when the shortcut is matched\n  }\n});\n```\n\nYubi is a powerful library for managing keyboard shortcuts with ease and flexibility. Unlike conventional libraries, Yubi seamlessly integrates with addEventListener, allowing for intuitive and readable shortcut definitions.\n\nIt not only supports simultaneous key combinations but also recognizes sequential commands.\n\n## Getting Started\n\nTo install Yubi, run:\n\n```bash\nnpm install yubi\n```\n\nThen, import it into your project with:\n\n```typescript\nimport { Yubi } from \"yubi\";\n```\n\nUsing Yubi is straightforward: create a persistent instance and leverage it in event handlers.\n\n```typescript\nconst yubi = new Yubi();\n\ndocument.addEventListener(\"keydown\", (e) =\u003e {\n  yubi.record(e); // Capture the event using the Yubi instance\n\n  if (yubi.match(\"cmd+s\")) {\n    // Code to be executed when the shortcut is matched\n  }\n});\n```\n\nFor detecting sequences like pressing `cmd+k` followed by `cmd+t`, concatenate them with a space:\n\n```typescript\ndocument.addEventListener(\"keydown\", (e) =\u003e {\n  yubi.record(e);\n\n  if (yubi.match(\"cmd+k cmd+t\")) {\n    // Code to be executed when the sequence is matched\n  }\n});\n```\n\nCustomize the interval for sequential commands and the command delimiter upon instancing.\n\n```typescript\nconst yubi = new Yubi({ delay: 500, delimiter: \"-\" });\n\n// Default settings are { delay: 1000, delimiter: \"+\" }\n```\n\n## String Format\n\nYubi's hotkey string format allows defining combinations and sequences of keys to trigger specific actions. Key components and examples below illustrate this syntax.\n\n### Basic Structure\n\n1. **Modifiers and Keys**: Connect modifier keys (e.g., `cmd`, `ctrl`) to regular keys (e.g., `k`, `t`) using the specified delimiter (default: `+`).\n2. **Sequences**: Use space to separate multiple hotkey combinations forming a sequence.\n\n### Default Delimiter\n\n- **Combination**: `cmd+k` (Press `command` and `k` together)\n- **Sequence**: `cmd+k cmd+t` (Press `command` and `k`, then `command` and `t`)\n\n### Custom Delimiter\n\nChange the delimiter by configuring the Yubi instance. For example, with a `-` delimiter:\n\n- **Combination**: `cmd-k`\n- **Sequence**: `cmd-k cmd-t`\n\n### Example Modifiers\n\nModifier Key | Keywords\n-------------|--------\nAlt          | Alt, alt, Option, option, ⌥\nCtrl         | Ctrl, ctrl, Control, control, ⌃\nShift        | Shift, shift, ⇧\nMeta         | Meta, meta, Command, command, Cmd, cmd, ⌘\n\n### Example Arrow Keys\n\nArrow Key     | Keywords\n--------------|---------\nArrowLeft     | left, arrowLeft, ArrowLeft\nArrowRight    | right, arrowRight, ArrowRight\nArrowUp       | up, arrowUp, ArrowUp\nArrowDown     | down, arrowDown, ArrowDown\n\nBy altering the `delimiter` option and structuring your hotkey strings according to the above format, you can craft personalized and versatile key command sequences with Yubi.\n\n## Development\n\nTo set up the development environment, run:\n\n```bash\nnpm install\nnpm test\n```\n\n## License\n\nThis library is distributed under the MIT license. See LICENSE for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoeki0%2Fyubi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoeki0%2Fyubi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoeki0%2Fyubi/lists"}