{"id":17736645,"url":"https://github.com/parro-it/keyboardevent-from-electron-accelerator","last_synced_at":"2025-07-04T23:33:34.464Z","repository":{"id":22132687,"uuid":"95384535","full_name":"parro-it/keyboardevent-from-electron-accelerator","owner":"parro-it","description":"Transform an Electron Accelerator string into a DOM KeyboardEvent.","archived":false,"fork":false,"pushed_at":"2023-01-04T21:36:46.000Z","size":1411,"stargazers_count":14,"open_issues_count":12,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-12T22:36:02.903Z","etag":null,"topics":[],"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/parro-it.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}},"created_at":"2017-06-25T20:38:16.000Z","updated_at":"2024-08-15T15:49:12.000Z","dependencies_parsed_at":"2023-01-11T21:29:41.454Z","dependency_job_id":null,"html_url":"https://github.com/parro-it/keyboardevent-from-electron-accelerator","commit_stats":null,"previous_names":["parro-it/keyboardevent-match-electron-accelerator"],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parro-it%2Fkeyboardevent-from-electron-accelerator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parro-it%2Fkeyboardevent-from-electron-accelerator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parro-it%2Fkeyboardevent-from-electron-accelerator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parro-it%2Fkeyboardevent-from-electron-accelerator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/parro-it","download_url":"https://codeload.github.com/parro-it/keyboardevent-from-electron-accelerator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249155161,"owners_count":21221550,"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-10-26T00:23:53.916Z","updated_at":"2025-04-15T21:23:35.030Z","avatar_url":"https://github.com/parro-it.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# keyboardevent-from-electron-accelerator\n\n[![Travis Build Status](https://img.shields.io/travis/parro-it/keyboardevent-from-electron-accelerator/master.svg)](http://travis-ci.org/parro-it/keyboardevent-from-electron-accelerator)\n[![NPM downloads](https://img.shields.io/npm/dt/keyboardevent-from-electron-accelerator.svg)](https://npmjs.org/package/keyboardevent-from-electron-accelerator)\n[![AppVeyor Build status](https://ci.appveyor.com/api/projects/status/l1qdd90e7xagkgq7/branch/master?svg=true)](https://ci.appveyor.com/project/parro-it/keyboardevent-from-electron-accelerator/branch/master)\n\n\u003e Transform an Electron Accelerator string into a DOM KeyboardEvent.\n\nThis module export a function that take an Electron Accelerator as input\nand return a corresponding KeyboardEvent object.\n\nE.g. `'Ctrl+Alt+C' =\u003e {code: 'c', ctrlKey: true, altKey: true}`\n\n## Usage\n\nThis example convert a string containing an Electron Accelerator to a corresponding KeyboardEvent object. Returned object is the keyevent that would be emitted if that key combination was pressed.\n\n```js\nconst {toKeyEvent} = require('keyboardevent-from-electron-accelerator');\nconsole.log(toKeyEvent('Shift+Delete'));\n```\n\nThis will output\n\n    {key: 'Delete', shiftKey: true}\n\n## Context and motivation for this module.\n\nThis module is part of an ongoing effort to make [electron-localshortcut](https://github.com/parro-it/electron-localshortcut) less error prone, using keyboard DOM listener instead of 'globalShortcut' method to trigger shortcuts handlers.\n\n`electron-localshortcut` will listen for DOM `keydown` and `keyup` events, and will\ntrigger shortcuts handlers if emitted DOM events match the Accelerator.\n\nThis module wrap the core logic of that match operation.\n\nYou can help by testing the module on [runkit](https://npm.runkit.com/keyboardevent-from-electron-accelerator) and [opening an issue](https://github.com/parro-it/keyboardevent-from-electron-accelerator/issues/new) if you found some wrong\nresult.\n\n\n## API\n\n\u003c!-- Generated by documentation.js. Update this documentation by updating the source code. --\u003e\n\n### toKeyEvent\n\nThis function transform an Electron Accelerator string into\na DOM KeyboardEvent object.\n\n**Parameters**\n\n-   `accelerator` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** an Electron Accelerator string, e.g. `Ctrl+C` or `Shift+Space`.\n\nReturns **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** a DOM KeyboardEvent object derivate from the `accelerator` argument.\n\n## Install\n\nWith [npm](https://npmjs.org/) installed, run\n\n    $ npm install keyboardevent-from-electron-accelerator\n\n## See Also\n\n-   [`noffle/common-readme`](https://github.com/noffle/common-readme)\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparro-it%2Fkeyboardevent-from-electron-accelerator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparro-it%2Fkeyboardevent-from-electron-accelerator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparro-it%2Fkeyboardevent-from-electron-accelerator/lists"}