{"_id":"@adariari/vue3-keyregister","_rev":"2-891a951827a94a2d589e30ea20cf6007","name":"@adariari/vue3-keyregister","dist-tags":{"latest":"0.2.1"},"versions":{"0.1.7":{"name":"@adariari/vue3-keyregister","private":false,"version":"0.1.7","type":"module","license":"MIT","main":"./dist/key-register.cjs.js","repository":{"type":"git","url":"git+https://github.com/allusernamestakenexceptthis/vue3-keyregister.git"},"scripts":{"dev":"vite","build":"vue-tsc && vite build","preview":"vite preview"},"dependencies":{"vue":"^3.2.47"},"devDependencies":{"@types/node":"^20.2.5","@vitejs/plugin-vue":"^4.1.0","path":"^0.12.7","rollup-plugin-typescript2":"^0.34.1","typescript":"^5.0.2","vite":"^4.3.2","vite-plugin-dts":"^2.3.0","vue-tsc":"^1.4.2"},"gitHead":"7525754a22b64d6cb7f12efaecd1a8502d417e7d","description":"Vue 3 plugin to register and unregister key sequences. rather than pressing keys at the same time, you can execute a callback after pressing keys in certain sequence.  such as h then e then l then l then o.","bugs":{"url":"https://github.com/allusernamestakenexceptthis/vue3-keyregister/issues"},"homepage":"https://github.com/allusernamestakenexceptthis/vue3-keyregister#readme","_id":"@adariari/vue3-keyregister@0.1.7","_nodeVersion":"17.3.0","_npmVersion":"8.3.0","dist":{"integrity":"sha512-VuDsDtpSTRg8gz2tO4U8sSAjWSd4iGLY59sHjNOSZnzDaeCOQRjpo5o3fGlN4KaDm3n+0EMGZGesBcSTO20uZA==","shasum":"96b677b604f1b24ef35b6e479a112c35c69e3e3a","tarball":"https://registry.npmjs.org/@adariari/vue3-keyregister/-/vue3-keyregister-0.1.7.tgz","fileCount":12,"unpackedSize":16443,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDDhkssHyeUlndbNSJ/Vl3ZIbMd0c9v2UocKxoTTw+QDwIhAPp+uMG7DJhhKnFD7UguuQlx+Wl+3Wt4GtiNAXX5DrIG"}]},"_npmUser":{"name":"adariari","email":"athary80@gmail.com"},"directories":{},"maintainers":[{"name":"adariari","email":"athary80@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vue3-keyregister_0.1.7_1685518960209_0.07049704382372934"},"_hasShrinkwrap":false},"0.2.0":{"name":"@adariari/vue3-keyregister","private":false,"version":"0.2.0","type":"module","license":"MIT","main":"./dist/key-register.cjs.js","repository":{"type":"git","url":"git+https://github.com/allusernamestakenexceptthis/vue3-keyregister.git"},"scripts":{"dev":"vite","build":"vue-tsc && vite build","preview":"vite preview"},"dependencies":{"vue":"^3.2.47"},"devDependencies":{"@types/node":"^20.2.5","@vitejs/plugin-vue":"^4.1.0","path":"^0.12.7","rollup-plugin-typescript2":"^0.34.1","typescript":"^5.0.2","vite":"^4.3.2","vite-plugin-dts":"^2.3.0","vue-tsc":"^1.4.2"},"gitHead":"d6d9c48f0f6534f696accf3a85c36983f6640f84","description":"Vue 3 plugin to register and unregister key sequences. rather than pressing keys at the same time, you can execute a callback after pressing keys in certain sequence.  such as h then e then l then l then o.","bugs":{"url":"https://github.com/allusernamestakenexceptthis/vue3-keyregister/issues"},"homepage":"https://github.com/allusernamestakenexceptthis/vue3-keyregister#readme","_id":"@adariari/vue3-keyregister@0.2.0","_nodeVersion":"17.3.0","_npmVersion":"8.3.0","dist":{"integrity":"sha512-RDomTD3ASc3IblrvCo1FgpvdFvLb+yRBB9JrM5HX44tIfmEDJmwZycHIBB9jWikxMxxwuUKpyslWri/RL9nktQ==","shasum":"ade10f9d6841861fa2649a26546605038e6d5874","tarball":"https://registry.npmjs.org/@adariari/vue3-keyregister/-/vue3-keyregister-0.2.0.tgz","fileCount":12,"unpackedSize":17344,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCMQG/ItaUPgsQedh6ck2StSUR56Tf2o6ivLA/UiUgy9wIgciyggccJTkK8c91eSA3mUuO7kxATk9ygZAvH5ni9xQ0="}]},"_npmUser":{"name":"adariari","email":"athary80@gmail.com"},"directories":{},"maintainers":[{"name":"adariari","email":"athary80@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vue3-keyregister_0.2.0_1685881617865_0.660158375005319"},"_hasShrinkwrap":false},"0.2.1":{"name":"@adariari/vue3-keyregister","private":false,"version":"0.2.1","type":"module","license":"MIT","main":"./dist/key-register.cjs.js","repository":{"type":"git","url":"git+https://github.com/allusernamestakenexceptthis/vue3-keyregister.git"},"scripts":{"dev":"vite","build":"vue-tsc && vite build","preview":"vite preview"},"dependencies":{"vue":"^3.2.47"},"devDependencies":{"@types/node":"^20.2.5","@vitejs/plugin-vue":"^4.1.0","path":"^0.12.7","rollup-plugin-typescript2":"^0.34.1","typescript":"^5.0.2","vite":"^4.3.2","vite-plugin-dts":"^2.3.0","vue-tsc":"^1.4.2"},"gitHead":"d6d9c48f0f6534f696accf3a85c36983f6640f84","description":"Vue 3 plugin to register and unregister key sequences. rather than pressing keys at the same time, you can execute a callback after pressing keys in certain sequence.  such as h then e then l then l then o.","bugs":{"url":"https://github.com/allusernamestakenexceptthis/vue3-keyregister/issues"},"homepage":"https://github.com/allusernamestakenexceptthis/vue3-keyregister#readme","_id":"@adariari/vue3-keyregister@0.2.1","_nodeVersion":"17.3.0","_npmVersion":"8.3.0","dist":{"integrity":"sha512-Wy4825GKM+h4eLe49ky2RsLYGyV2siV99Pmj9j1UESF7cSG/t8c2GyildaAd5Op+c51dQnG8Mz9reVuIgX9X+Q==","shasum":"9fe7bbaca80f34d23eac80225a5be13c4f4ab473","tarball":"https://registry.npmjs.org/@adariari/vue3-keyregister/-/vue3-keyregister-0.2.1.tgz","fileCount":12,"unpackedSize":20375,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICmWeQ5l/XG1JQZkvJ2K5P3XPMH7j0E6j8pVtwLozKXPAiAvm9FHxarMQtrLOypwaJtCoxU3Lz5DWnMj3Zn6Uv34SA=="}]},"_npmUser":{"name":"adariari","email":"athary80@gmail.com"},"directories":{},"maintainers":[{"name":"adariari","email":"athary80@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vue3-keyregister_0.2.1_1685882285270_0.9325507960357458"},"_hasShrinkwrap":false}},"time":{"created":"2023-05-31T07:42:40.149Z","0.1.7":"2023-05-31T07:42:40.363Z","modified":"2023-06-04T12:38:05.603Z","0.2.0":"2023-06-04T12:26:58.040Z","0.2.1":"2023-06-04T12:38:05.482Z"},"maintainers":[{"name":"adariari","email":"athary80@gmail.com"}],"description":"Vue 3 plugin to register and unregister key sequences. rather than pressing keys at the same time, you can execute a callback after pressing keys in certain sequence.  such as h then e then l then l then o.","homepage":"https://github.com/allusernamestakenexceptthis/vue3-keyregister#readme","repository":{"type":"git","url":"git+https://github.com/allusernamestakenexceptthis/vue3-keyregister.git"},"bugs":{"url":"https://github.com/allusernamestakenexceptthis/vue3-keyregister/issues"},"license":"MIT","readme":"# Vue 3 Key Register\n\nVue 3 plugin to register and unregister key sequences. rather than pressing keys at the same time, you can execute a callback after pressing keys in certain sequence.  such as h then e then l then l then o.\n\n## installation\n\n```bash\nnpm install @adariari/vue3-keyregister\n```\n\nthen in main.ts/main.js, add:\n\n```javascript\nimport KeyRegister from '@adariari/vue3-keyregister'\n...\n.use(KeyRegister)\n\n```\n\nFull example of main.js\n\n```javascript\nimport { createApp } from 'vue'\nimport App from './App.vue'\nimport KeyRegister from '@adariari/vue3-keyregister'\n\n\ncreateApp(App)\n    .use(KeyRegister)\n    .mount('#app')\n\n```\n\n## Example of use\n\n```vue\n<script setup>\n    import { ref } from 'vue'\n    // import composable useKeyRegister to register keys and change options\n    import { useKeyRegister } from '@adariari/vue3-keyregister'\n\n    const keyPressed = ref('');\n\n    //register sequence hello,  and execute callback\n    useKeyRegister().registerKeySequence({\n        keyIdentity: 'h+e+l+l+o',\n        callback: (key) => {\n            console.log(key);\n            keyPressed.value = key;\n        }\n    })\n\n    //register sequence bye\n    useKeyRegister().registerKeySequence({\n        keyIdentity: 'b+y+e',\n        callback: (key) => {\n            console.log(key);\n            keyPressed.value = key;\n        }\n    })\n</script>\n\n\n<template>\n  key pressed : {{ keyPressed }}\n</template>\n\n```\n\n## Methods\n\n### RegisterKeySequence\n\n```yml\nuseKeyRegister().registerKeySequence (\n    RegisteryProps: object\n)\n```\n\nRegistryProps can accept following options:\n\n```javascript\n/*\n     @key string keyIdentity unique identity of key sequence such as 'hello' or 'bye', maybe used as key|identity\n     @key string key sequence of keys such as 'ctrl+shift+alt+key' or m+m or c+a\n     @key boolean once if true, callback will be executed only once\n     @key function callback (targetKey : string, lastEvent : KeyboardEvent) => void\n     @key function|null validateTargetCallback callback to validate target\n*/\n```\n\nkey Or keyIdentity required\ncallback also required\n\nkeyIdentity can be used as identity only, or to specifiy key e.g.\n\n```yml\nkeyIdentity: \"c+c|my cc key\"\n```\n\nthis both sets key as c+c and use keyIdentity c+c|my cc key\n\nor you can set them separately:\n\n```yml\nkey: \"c+c\",\nkeyIdentity: \"my cc key\"\n```\n\nyou can also just set the key, but cautious that when you remove the key in this case, it will remove all mentions of it from any component\n\n### unregisterKeySequence\n\nThis can unregister the sequence by keyIdentity, it will remove any registered key matching the identity\n\n```javascript\nuseKeyRegister().unregisterKeySequence(\"c+c|my cc key\");\n```\n\n### registerSequenceListener\n\nRegister a listener for sequences, to customize action and process. return true if there is match or false if none\n\n```yml\nuseKeyRegister().registerSequenceListener (\n    ListenProps: object\n)\n```\n\nListenProps can accept following options:\n\n```javascript\n/*\n    @key options ListenerProps consists of \n            listener a callback that should take \n            (sequence : array<string> containing sequence of keys, lastEvent : KeyboardEvent) => boolean\n            Boolean value should be returned to indicate if the sequence is matched\n    @key Once if true, listener will be executed only once\n*/\n```\n\n### unregisterSequenceListener\n\nUnregister listener\n\n```javascript\n/*\n@param listener to be unregistered\n*/\nYou should pass same function you passed to register listener\n\n\n## Options\n\nYou can set options globally either in main or in any component using composable\n\nAvailable options:\n\n```yml\n// Timeout in milliseconds to wait for the next keypress\ntimeout: 500,\n// Timeout in milliseconds to block key events after a key sequence is matched\nblockingDelay: 10,\n```\n\n### composable\n\n```javascript\nconst { options } = useKeyRegister();\n\n//can set global timeout for all key sequences\noptions.timeout = 1000;\n```\n\n### main\n\n```javascript\nconst app = createApp(App);\napp.use(KeyRegister,{\n    // Timeout in milliseconds to wait for the next keypress\n    timeout: 500,\n    // Timeout in milliseconds to block key events after a key sequence is matched\n    blockingDelay: 10,\n});\napp.mount('#app');\n```\n","readmeFilename":"README.md"}