{"_id":"@apsc/keyboard-shortcut-action","_rev":"3-5fa66873a0698e65e053a75d89b5ff4e","name":"@apsc/keyboard-shortcut-action","dist-tags":{"latest":"0.0.4"},"versions":{"0.0.1":{"name":"@apsc/keyboard-shortcut-action","description":"Action to call a function by keyboard shortcut for Svelte directive use:","type":"module","version":"0.0.1","author":{"name":"Andrey Pavlenko"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/andrey-pavlenko/svelte-components.git"},"bugs":{"url":"https://github.com/andrey-pavlenko/svelte-components/issues"},"keywords":["svelte","action","KeyboardEvent","keycode"],"homepage":"https://github.com/andrey-pavlenko/svelte-components/tree/main/packages/keyboard-shortcut-action#readme","dependencies":{"keyboard-event-to-string":"^2.1.0"},"exports":{"./package.json":"./package.json",".":"./index.js"},"types":"./index.d.ts","_id":"@apsc/keyboard-shortcut-action@0.0.1","_integrity":"sha512-5OHMAsn2dgWwgEdvHwvrUtOThsBa9m+kLVfvxtMqjSBlFh7Cddv0wiaDXW4NgBvVcFRaMfJXOCWP8MjqysEpuA==","_resolved":"/tmp/4b991b2556438a56b8eae5051d19e021/apsc-keyboard-shortcut-action-0.0.1.tgz","_from":"file:apsc-keyboard-shortcut-action-0.0.1.tgz","_nodeVersion":"18.3.0","_npmVersion":"8.5.5","dist":{"integrity":"sha512-5OHMAsn2dgWwgEdvHwvrUtOThsBa9m+kLVfvxtMqjSBlFh7Cddv0wiaDXW4NgBvVcFRaMfJXOCWP8MjqysEpuA==","shasum":"885bfc80c0ad867155ee5c48dd4647815145bf94","tarball":"https://registry.npmjs.org/@apsc/keyboard-shortcut-action/-/keyboard-shortcut-action-0.0.1.tgz","fileCount":5,"unpackedSize":9247,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICCTo0vTvuLQijtUk2NOv8thhemTuIsQl68dZG060DkGAiEA6M6Rs/FXa6El8XORCq9grqJih1IaE/QqPPlD2Teu+Xk="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiotctACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrwSxAAgR1goitNinP0KXy/6lmE79Qd0wyEVZekUsCGKJs+i1bnaXyf\r\nbEXkvUmo/5wuNBZW6BODKgqINuAYTF1QcICnza3xmUkhViqo/DF2Nlc7OWLC\r\nk2JBazKaBmEYWlccrImRgB+2RB5isnW+Uvqy1Ju0HiP3n+T9wrDxy/I+dlGT\r\nDonKVayHzAG+HG2uJmAqa+CAtMu0UNEvrI+m7hAmnR31Nn0fWNRBS2MdlZPH\r\nboaaVDxFV1Bgvk5szWmSbTJK+unqppo1566YWg9iw+F7asdqKeYNkJWizBAa\r\nhTyeQ2T2AYQ3kFoo0on+outHnLbQFB/i4v9cEEOT2dmVG5IO3zP/S/p8xo7f\r\nCvf1N8F47/hTpdzfyMSLzjbD9c8BDOQIg+FULl8qEi0n7lChFms7RTonK+E6\r\nL8mzNZZXxzIHsDBPuLscK9s3bvb6BZkPAULoj35wDHPYzG2QGklp5m3hVoPp\r\nnuJT/UdVbL9RGGikSyxir+85G/PvPv2247bknk8Epf9utLCHsFlNTdxmUKOC\r\nb7EEzfod9x1BRlysdVw0GGfFfh3WkeXhDiHumVgptKOIGIP+GmdTmvvq8Ve7\r\nZIMVA7yNotJnPdeVLNSiVvcUi66joEfn+4KQsoLIxSPoOrBLFVlYSKTMeKsa\r\ndj9fsU6JROqY9hhZzeJdyAPqkI/8hoc+R60=\r\n=iBKz\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"andrey-pavlenko","email":"andrey.pavlenko@mail.ru"},"directories":{},"maintainers":[{"name":"andrey-pavlenko","email":"andrey.pavlenko@mail.ru"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/keyboard-shortcut-action_0.0.1_1654839085464_0.4367358707874458"},"_hasShrinkwrap":false},"0.0.2":{"name":"@apsc/keyboard-shortcut-action","description":"Action to call a function by keyboard shortcut for Svelte directive use:","type":"module","version":"0.0.2","types":"index.d.ts","main":"index.js","svelte":"./index.js","author":{"name":"Andrey Pavlenko"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/andrey-pavlenko/svelte-components.git"},"bugs":{"url":"https://github.com/andrey-pavlenko/svelte-components/issues"},"keywords":["svelte","action","KeyboardEvent","keycode"],"homepage":"https://github.com/andrey-pavlenko/svelte-components/tree/main/packages/keyboard-shortcut-action#readme","dependencies":{"keyboard-event-to-string":"^2.1.0"},"peerDependencies":{"svelte":"^3.50.1"},"exports":{"./package.json":"./package.json",".":"./index.js"},"_id":"@apsc/keyboard-shortcut-action@0.0.2","_integrity":"sha512-8NEPykTM6CWHQSczvvy9DbxLQx9iIex/Ygzj8Trh9opY/5Bbr96z1QZObYLHGvhhDhdcYmcXypwaWDjTZmmiVw==","_resolved":"/tmp/71bb2ab03e2dbe0c3c746a459babd34d/apsc-keyboard-shortcut-action-0.0.2.tgz","_from":"file:apsc-keyboard-shortcut-action-0.0.2.tgz","_nodeVersion":"18.10.0","_npmVersion":"8.19.2","dist":{"integrity":"sha512-8NEPykTM6CWHQSczvvy9DbxLQx9iIex/Ygzj8Trh9opY/5Bbr96z1QZObYLHGvhhDhdcYmcXypwaWDjTZmmiVw==","shasum":"a05f55d11a31140fd6c9bb5a4c13cb64ae193a93","tarball":"https://registry.npmjs.org/@apsc/keyboard-shortcut-action/-/keyboard-shortcut-action-0.0.2.tgz","fileCount":6,"unpackedSize":9423,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEBt8h/zkt3+tHQLC3gRjeQ+hut8eSbjKLA69GedGjTQAiEAmovohf0ilZbjRN4hMGRsJzVSa+ulQuQan6YPXP9gsrQ="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjOdffACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqnEA/9HznU8Yjzf9OXD2rRKmdjHm4HxsX1G1Q/Bg/K6f2azKRqnASD\r\nGWiPNDNzViSfDzYMvpEN/afQ83T6Tdr9YdfEc7bYTcKr285hMUgLMp/XhQ7b\r\ncPhNpEq5G64gvpmCVRoPahlj9wQ9frzOe5x3CZWgZwzfzW0Mc/SRnaN5UbDb\r\nAWjAgPNxblrEmYs6Wey5TeCeDcswfr1yM6D82uec3YbFhSeaCSja7YvHMm4q\r\nUrT2Ct9Y1YS9vMZcht0qYYz4rHYF3U2a0rpcL72ywfQmOXgP0s3SNzNdiB9P\r\n6M96pRlSagz4poS4SJH0j8phs+3knTcORhIOqwgY4KYeewsaj+QqGRH/f+Fx\r\n84OfgG5X5/J/AOXjNvj34nxg9vF54GyC12TYgE2lTNU/XZuWfGge/w8pQtmN\r\nv0du1j1EXhizlL5x+zJuUgGuXWB6qxETSjcFllABMaSqRJnx6NCpzSVW/7T7\r\nZYal3uBOLfZVsiaklfE7wv0Wlyx8xd+8UlB6QCMnVpFOHtPKbxSlRNoRtng0\r\naV1rmPYxe+97GwNCAPWlEEoa/ftDH6/V3eUZQevyvWtSatJsYRYsT/vPO/SG\r\n87cKdJZC4KEfR6VQmU8cRRk1N0xstRpG3Pzt5gwEqzQoHeupinzjs3155hod\r\nYn0gpJiTEgvl3RpS9uWUdxkvhj1Wx5yUBcY=\r\n=HR3y\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"andrey-pavlenko","email":"andrey.pavlenko@mail.ru"},"directories":{},"maintainers":[{"name":"andrey-pavlenko","email":"andrey.pavlenko@mail.ru"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/keyboard-shortcut-action_0.0.2_1664735199611_0.8509852579747434"},"_hasShrinkwrap":false},"0.0.3":{"name":"@apsc/keyboard-shortcut-action","description":"Action to call a function by keyboard shortcut for Svelte directive use:","type":"module","version":"0.0.3","types":"index.d.ts","main":"index.js","svelte":"./index.js","pathPkg":"../../packages/keyboard-shortcut-action","author":{"name":"Andrey Pavlenko"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/andrey-pavlenko/svelte-components.git"},"bugs":{"url":"https://github.com/andrey-pavlenko/svelte-components/issues"},"keywords":["svelte","action","KeyboardEvent","keycode"],"homepage":"https://github.com/andrey-pavlenko/svelte-components/tree/main/packages/keyboard-shortcut-action#readme","dependencies":{"keyboard-event-to-string":"^2.1.0"},"peerDependencies":{"svelte":"^3.30.0"},"devDependencies":{"@sveltejs/adapter-auto":"^1.0.2","@sveltejs/kit":"^1.3.6","@sveltejs/package":"^1.0.2","svelte":"^3.55.1","svelte-check":"^3.0.3","svelte-preprocess":"^5.0.1","tslib":"^2.5.0","typescript":"^4.9.5","vite":"^4.0.4"},"exports":{".":"./index.js"},"scripts":{"dev":"vite dev --port 3000","build":"svelte-kit sync && svelte-package","check":"svelte-kit sync && svelte-check --tsconfig ./tsconfig.json","check:watch":"svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch","format":"cd $npm_package_pathPkg && prettier --plugin-search-dir . --write .","changelog":"../../node_modules/.bin/conventional-changelog -n ../changelog-config.cjs --commit-path=. > $npm_package_pathPkg/CHANGELOG.md","finish:package":"cd $npm_package_pathPkg && npe --delete devDependencies pathPkg","package":"pnpm run check && svelte-package && pnpm run finish:package && pnpm run format && pnpm changelog"},"_id":"@apsc/keyboard-shortcut-action@0.0.3","_integrity":"sha512-xLjz7SXnEmjg2bQHNj6hf8ArgFZ6wA7xDlDNm+4SSmDRS2hvpCD8Vt3nbaZkNBpMwFZiB8dAFZzw8cJBHWvvkQ==","_resolved":"/tmp/df710582fdee90648b1fc4873135de77/apsc-keyboard-shortcut-action-0.0.3.tgz","_from":"file:apsc-keyboard-shortcut-action-0.0.3.tgz","_nodeVersion":"19.5.0","_npmVersion":"8.19.2","dist":{"integrity":"sha512-xLjz7SXnEmjg2bQHNj6hf8ArgFZ6wA7xDlDNm+4SSmDRS2hvpCD8Vt3nbaZkNBpMwFZiB8dAFZzw8cJBHWvvkQ==","shasum":"7bb84ddb90861697a5c45d7943e13ed19eef0100","tarball":"https://registry.npmjs.org/@apsc/keyboard-shortcut-action/-/keyboard-shortcut-action-0.0.3.tgz","fileCount":21,"unpackedSize":27657,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIB/HcKHCGGSwGapcVuC5+WgfW6Z/8a5zJxK7aiJgBFy5AiBAj+7S5eVuQ5fjKl8MpFKVSYKkwOdGUqZ6aoNANunh/Q=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj2sUIACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpgjQ//V1EVEd4ytm2LrdpmxAtMKwVHeuX+IiMFdG73t/iaTpJrfM7u\r\nd8DQodTpA6W61R9K7RPIgFVSZyupduIGgvp6GZ48T23HDJfM4jrrmlm4fEqX\r\n3oNex1qY8nDofS4Mxjd/f/EoHh/Vlire60cKzDFWHE+nBOXzEstSohcf5f5Y\r\n1RvhKtD8CRdSP/1yEz5w3WIGwVCC6U8PyMmkVYlf/fR+4iT0WaUYcIYtXPSh\r\n0S34XyUz+0/AJ6xtm1ZTqkyXyDqL9M2uBXi4YAY4sYwfBH63rxKi6iIDldJp\r\nxuDGo5nBbBEeA7/oDE88LkrpslZ4xtRd9i3Vhd178lmQ97IqnJldENZsodhh\r\nnRewuIK8wzLDj14TxgoaFOZRI9O0zeDd/TwYwiVxpXgymCPXZgXO7E3C6INw\r\nEdz2ZuVJW2pHiFaK0KTKgCxZzZmbbxY12iBYiB7XGNaMl7iWPbl69qQUW6qm\r\nbcwN5V7u90x0cuK2Dly/wYgWUcu2Ny+9AWCQWBHz3EKIccbGUTraCQLdzYiK\r\nH5NW/lBJR76bTcuLHKn/dgCvaEQ/YeU3UNV8SwKZXqsvMWdcQOR+IecRfgPz\r\nZK5+3/QnYlQqe5noAAK3YoXwVdf9XDcSUISEXLfPVxrZIf03tn1AbiruVFv/\r\nBKLzM+2OrJ7wpusrf3NutDfp3Yh1/aG1IDA=\r\n=iznx\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"andrey-pavlenko","email":"andrey.pavlenko@mail.ru"},"directories":{},"maintainers":[{"name":"andrey-pavlenko","email":"andrey.pavlenko@mail.ru"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/keyboard-shortcut-action_0.0.3_1675281672587_0.7373228572086552"},"_hasShrinkwrap":false},"0.0.4":{"name":"@apsc/keyboard-shortcut-action","description":"Action to call a function by keyboard shortcut for Svelte directive use:","type":"module","version":"0.0.4","types":"index.d.ts","main":"index.js","svelte":"./index.js","author":{"name":"Andrey Pavlenko"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/andrey-pavlenko/svelte-components.git"},"bugs":{"url":"https://github.com/andrey-pavlenko/svelte-components/issues"},"keywords":["svelte","action","KeyboardEvent","keycode"],"homepage":"https://github.com/andrey-pavlenko/svelte-components/tree/main/packages/keyboard-shortcut-action#readme","dependencies":{"keyboard-event-to-string":"^2.1.0"},"peerDependencies":{"svelte":"^3.30.0"},"exports":{"./package.json":"./package.json",".":"./index.js"},"gitHead":"915c3b0f43eec7b79a0cdb8aaeddf5a84205b791","_id":"@apsc/keyboard-shortcut-action@0.0.4","_nodeVersion":"19.5.0","_npmVersion":"8.19.2","dist":{"integrity":"sha512-0yqnim+u+MlFeDdBBKskvMBbi/fWRTVPEECawXEO9R1TzPg6aValv2XCIUxiiWtdO3vpS79SfVyCvirTaDgCXw==","shasum":"48a6747b43ed665d283b3e62ea35ab85465e831a","tarball":"https://registry.npmjs.org/@apsc/keyboard-shortcut-action/-/keyboard-shortcut-action-0.0.4.tgz","fileCount":5,"unpackedSize":8288,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDBGRAyx32J0sI9F3BbCIW0Vn9N0bA8AsTZxyCBirGxSAiAzJAPDh+ol+TsbykT96npfmNR759SNy5+oYXckZOsN8g=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj2shiACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmog5g/+OKQQfTsync+KpguRdx/xoP7l5SbQ94U6/tZvx/sNUm/mY1Rz\r\nYQ454bdBsRzliojpKP9ql1tLpw8d0cPZVHBLGXTTY4JODfE6NPbFlu8YesZS\r\nrvsFOIu1KoWLst0oNLqN7QlH3FDyfdI9m08pRazFD+Hmj6rEXblxgb4+Qq5x\r\nw1V9eAK7+DYplRiiSxssxZ2Pk3ZDMAuXjCZ09Xcu9RfA7Rb5bO657DyMzV6D\r\nHegS0TIoV4M2Yj9Urnt8Bvw+Hw36WAKXjrTCuv19BGCzAlvsaZgvzutUJ7jU\r\ncl+rNEneikXYBePa4bELM9p8GPHPezG7Kf6BJIy473t9QrAQ2XBBm6Xo0Kza\r\n7qbymofK+f5nZOAQ9CSEV32Gmd56RoBJAxKWz8PoaUNmDkVjj382Oq9qgV++\r\nWfoXfs3yI+7dBxoheaoHFR9Xh32sxu1wjysZE6JK+Q35YXeiNHdowP1No8ta\r\ncYVfE+UQKWphO4bkME/yobIm/4ODjGqyp5Pw3BvCD/QPvh20LN7mA55ujOnS\r\nQ6KyTXAWUigR3pZLrVRgukImAgKQX49XEoAOMJYLR+3IbpenGy5Jl3/ZxZRB\r\nvnpmpxgEcKXUd5+7tde1Z9/oSYlsBMF0k26XfxZt6Y9LrkDJbbJlCW8UeIa+\r\nwxwlFNuu2OKHKs2LJM/HJt/Sn3vOmdTjBUI=\r\n=sLq9\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"andrey-pavlenko","email":"andrey.pavlenko@mail.ru"},"directories":{},"maintainers":[{"name":"andrey-pavlenko","email":"andrey.pavlenko@mail.ru"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/keyboard-shortcut-action_0.0.4_1675282529954_0.14367876321547723"},"_hasShrinkwrap":false}},"time":{"created":"2022-06-10T05:31:25.395Z","0.0.1":"2022-06-10T05:31:25.630Z","modified":"2023-02-01T20:15:30.334Z","0.0.2":"2022-10-02T18:26:39.817Z","0.0.3":"2023-02-01T20:01:12.789Z","0.0.4":"2023-02-01T20:15:30.166Z"},"maintainers":[{"name":"andrey-pavlenko","email":"andrey.pavlenko@mail.ru"}],"description":"Action to call a function by keyboard shortcut for Svelte directive use:","homepage":"https://github.com/andrey-pavlenko/svelte-components/tree/main/packages/keyboard-shortcut-action#readme","keywords":["svelte","action","KeyboardEvent","keycode"],"repository":{"type":"git","url":"git+https://github.com/andrey-pavlenko/svelte-components.git"},"author":{"name":"Andrey Pavlenko"},"bugs":{"url":"https://github.com/andrey-pavlenko/svelte-components/issues"},"license":"MIT","readme":"# Action to call a function by keyboard shortcut for Svelte directive `use`\n\n- allows to reduce keyboard event handling code\n- dependence [`keyboard-event-to-string`](https://www.npmjs.com/package/keyboard-event-to-string)\n\n### [Docs & Demo](https://andrey-pavlenko.github.io/svelte-components/?c=keyboard-shortcut-action)\n\n## Install\n\n### NPM\n\n```sh\nnpm i -D @apsc/keyboard-shortcut-action\n```\n\n### PNPM\n\n```sh\npnpm add -D @apsc/keyboard-shortcut-action\n```\n\n## API\n\n```ts\nlet active = 0;\nconst items = [...Array(20).keys()].map((i) => ({\n  id: i + 1,\n  message: `Text #${(i + 1).toString().padStart(2, '0')}`\n}));\n\n<div\n  tabindex=\"0\"\n  use:useKeyboardShortcut={{\n    event: 'keydown',\n    preventDefault: true,\n    fns: {\n      'Ctrl+ArrowUp': () => (active = 0),\n      'ArrowUp': () => (active = Math.max(0, active - 1)),\n      'Ctrl+ArrowDown': () => (active = items.length - 1),\n      'ArrowDown': () => (active = Math.min(items.length - 1, active + 1))\n    }\n  }}\n>\n  {#each items as item, index}\n    <div class:active={active === index}>{item.id} {item.message}</div>\n  {/each}\n</div>\n```\n\n#### useKeyboardShortcut options\n\n```ts\nexport interface UseKeyboardShortcutOptions {\n  event: 'keypress' | 'keydown' | 'keyup';\n  capture?: boolean; // default false\n  passive?: boolean; // default false\n  preventDefault?: boolean; // default false\n  stopPropagation?: boolean; // default false\n  stopImmediatePropagation?: boolean; // default false\n  fns: Record<string, (event: KeyboardEvent) => void>;\n}\n```\n\n#### Lifecycle\n\nThe action attaches a handler to the corresponding event `options.event` with parameters\n\n- `capture`\n- `passive`\n\nThe handler converts event to `shortcut` using package [`keyboard-event-to-string`](https://www.npmjs.com/package/keyboard-event-to-string).\n\nIf function `options.fns[shortcut]` exists then handler executes\n\n- `event.preventDefault()` if `options.preventDefault == true`\n- `event.stopPropagation()` if `options.stopPropagation == true`\n- `event.stopImmediatePropagation()` if `options.stopImmediatePropagation == true`\n\nAfter it calls `options.fns[shortcut](event)`.\n\n**Note!** The action modifies [global options](https://github.com/ndp-software/keyboard-event-to-string#options)\n\n```js\nsetOptions({ joinWith: '+' });\n```\n\nTherefore, the shortcut obtained in the action are `Ctrl+A` instead `Ctrl + A`.\n","readmeFilename":"README.md"}