{"id":13580707,"url":"https://github.com/brtnshrdr/angular2-hotkeys","last_synced_at":"2025-04-09T06:12:42.628Z","repository":{"id":8911036,"uuid":"59851815","full_name":"brtnshrdr/angular2-hotkeys","owner":"brtnshrdr","description":"Keyboard shortcuts for Angular 2 apps","archived":false,"fork":false,"pushed_at":"2024-01-15T15:55:32.000Z","size":544,"stargazers_count":204,"open_issues_count":34,"forks_count":94,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-04-08T14:44:52.837Z","etag":null,"topics":["angular","angular2","hotkeys","typescript"],"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/brtnshrdr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2016-05-27T17:28:01.000Z","updated_at":"2025-04-03T17:52:20.000Z","dependencies_parsed_at":"2024-05-11T22:35:48.976Z","dependency_job_id":"69148d90-8cef-41f8-8e0c-f7ab3c5e96eb","html_url":"https://github.com/brtnshrdr/angular2-hotkeys","commit_stats":{"total_commits":99,"total_committers":18,"mean_commits":5.5,"dds":0.7272727272727273,"last_synced_commit":"e6f3604fbddc0a4e5468eadfcf42276638fb2678"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brtnshrdr%2Fangular2-hotkeys","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brtnshrdr%2Fangular2-hotkeys/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brtnshrdr%2Fangular2-hotkeys/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brtnshrdr%2Fangular2-hotkeys/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brtnshrdr","download_url":"https://codeload.github.com/brtnshrdr/angular2-hotkeys/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247987285,"owners_count":21028895,"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":["angular","angular2","hotkeys","typescript"],"created_at":"2024-08-01T15:01:54.401Z","updated_at":"2025-04-09T06:12:42.604Z","avatar_url":"https://github.com/brtnshrdr.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","Table of contents","Services"],"sub_categories":["Third Party Components","Other"],"readme":"# angular2-hotkeys\nAngular 16 and Ivy Compatible. Older versions might work but isn't officially tested.\n\n## Versions compatibility\nv2.4.0 - Angular 11 (most likely lower Angular versions)\n\nv13.*.* - Angular 13 (most likely Angular 12)\n\nv15.*.* - Angular 15\n\nv16.*.* - Angular 16\n\n## Installation\n\nTo install this library, run:\n\n```bash\n$ npm install angular2-hotkeys --save\n```\n\n## Examples\nFirst, import the HotkeyModule into your root AppModule\n\n```typescript\nimport {HotkeyModule} from 'angular2-hotkeys';\n```\n\nThen, add HotkeyModule.forRoot() to your AppModule's import array\n\n```typescript\n@NgModule({\n    imports : [CommonModule, HotkeyModule.forRoot(), ...],\n})\nexport class AppModule {}\n```\n\nIf you have any sub/feature modules that also use hotkeys, import the HotkeyModule (but NOT .forRoot())\n```typescript\n@NgModule({\n    imports : [CommonModule, HotkeyModule, ...],\n})\nexport class SharedModule {}\n```\n\nThen inject the service into your constructor and add a new hotkey\n\n```typescript\nconstructor(private _hotkeysService: HotkeysService) {\n    this._hotkeysService.add(new Hotkey('meta+shift+g', (event: KeyboardEvent): boolean =\u003e {\n        console.log('Typed hotkey');\n        return false; // Prevent bubbling\n    }));\n}\n```\nIt also handles passing an array of hotkey combinations for a single callback\n```typescript\nthis._hotkeysService.add(new Hotkey(['meta+shift+g', 'alt+shift+s'], (event: KeyboardEvent, combo: string): ExtendedKeyboardEvent =\u003e {\n    console.log('Combo: ' + combo); // 'Combo: meta+shift+g' or 'Combo: alt+shift+s'\n    let e: ExtendedKeyboardEvent = event;\n    e.returnValue = false; // Prevent bubbling\n    return e;\n}));\n```\n\nYour callback must return either a boolean or an \"ExtendedKeyboardEvent\".\n\nFor more information on what hotkeys can be used, check out \u003chttps://craig.is/killing/mice\u003e\n\nThis library is a work in progress and any issues/pull-requests are welcomed!\nBased off of the [angular-hotkeys library](https://github.com/chieffancypants/angular-hotkeys)\n\n## Cheat Sheet\n\nTo enable the cheat sheet, simply add `\u003chotkeys-cheatsheet\u003e\u003c/hotkeys-cheatsheet\u003e` to your top level component template.\nThe `HotkeysService` will automatically register the `?` key combo to toggle the cheat sheet.\n\n**NB!** Only hotkeys that have a description will apear on the cheat sheet. The Hotkey constructor takes a description as\nan optional fourth parameter as a string or optionally as a function for dynamic descriptions.\n\n```typescript\nthis._hotkeysService.add(new Hotkey('meta+shift+g', (event: KeyboardEvent): boolean =\u003e {\n    console.log('Secret message');\n    return false;\n}, undefined, 'Send a secret message to the console.'));\n```\n\nThe third parameter, given as `undefined`, can be used to allow the Hotkey to fire in INPUT, SELECT or TEXTAREA tags.\n\n### Cheat Sheet Customization\n\n1. You can now pass in custom options in `HotkeyModule.forRoot(options: IHotkeyOptions)`.\n\n```typescript\nexport interface IHotkeyOptions {\n  /**\n   * Disable the cheat sheet popover dialog? Default: false\n   */\n  disableCheatSheet?: boolean;\n  /**\n   * Key combination to trigger the cheat sheet. Default: '?'\n   */\n  cheatSheetHotkey?: string;\n  /**\n   * Use also ESC for closing the cheat sheet. Default: false\n   */\n  cheatSheetCloseEsc?: boolean;\n  /**\n   * Description for the ESC key for closing the cheat sheet (if enabed). Default: 'Hide this help menu'\n   */\n  cheatSheetCloseEscDescription?: string;\n  /**\n   * Description for the cheat sheet hot key in the cheat sheet. Default: 'Show / hide this help menu'\n   */\n  cheatSheetDescription?: string;\n};\n```\n\n2. You can also customize the title of the cheat sheet component.\n\n```html\n\u003chotkeys-cheatsheet title=\"Hotkeys Rock!\"\u003e\u003c/hotkeys-cheatsheet\u003e\n\u003c!-- Default: 'Keyboard Shortcuts:' --\u003e\n```\n\n## TODO\n1. Create unit and E2E tests\n\n## Development\n\nTo generate all `*\n}.js`, `*.js.map` and `*.d.ts` files:\n\n```bash\n$ npm run tsc\n```\n\n## License\n\nMIT © [Nick Richardson](nick.richardson@mediapixeldesign.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrtnshrdr%2Fangular2-hotkeys","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrtnshrdr%2Fangular2-hotkeys","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrtnshrdr%2Fangular2-hotkeys/lists"}