{"_id":"@amruthlp/hotkeys","_rev":"2-a64991f59dcfb2121bdde838a8c66574","name":"@amruthlp/hotkeys","dist-tags":{"latest":"1.1.1"},"versions":{"1.0.0":{"name":"@amruthlp/hotkeys","version":"1.0.0","keywords":[],"author":"","license":"ISC","_id":"@amruthlp/hotkeys@1.0.0","maintainers":[{"name":"amruthlp","email":"amruthgowd91200@gmail.com"}],"dist":{"shasum":"c7764d76a798cec28301972b0c4351bf0bf21529","tarball":"https://registry.npmjs.org/@amruthlp/hotkeys/-/hotkeys-1.0.0.tgz","fileCount":6,"integrity":"sha512-/HNnD4ktuMLPQ9FhkM8c5+K1rTjTBB9AAoOr0FFw0Q0sGoI79kbsNMugx1G7VPkZiZ9zz2f6kUKj9mD03iBoXA==","signatures":[{"sig":"MEUCIQCFHHocNeYNFe/DBXI7yJ9tGt6CCzXXggoQMiR4x49LDQIgOlXxqAeivmk7PEDtnQ7DrgsodagdvZ3hhVe/CKIbcsI=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":3671},"main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc"},"_npmUser":{"name":"amruthlp","email":"amruthgowd91200@gmail.com"},"_npmVersion":"10.8.3","directories":{},"_nodeVersion":"21.1.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.6.2","@types/node":"^22.6.1","@types/react":"^18.3.8"},"peerDependencies":{"next":"^14.2.13","react":"^18.3.1"},"_npmOperationalInternal":{"tmp":"tmp/hotkeys_1.0.0_1727160670555_0.4746975803857776","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"@amruthlp/hotkeys","version":"1.0.1","keywords":[],"author":"","license":"ISC","_id":"@amruthlp/hotkeys@1.0.1","maintainers":[{"name":"amruthlp","email":"amruthgowd91200@gmail.com"}],"dist":{"shasum":"bf666e3a0a31ca90c90f8bdf26538bb3900a6ae5","tarball":"https://registry.npmjs.org/@amruthlp/hotkeys/-/hotkeys-1.0.1.tgz","fileCount":6,"integrity":"sha512-mcE3jn1GpVGBbbrcrrSMUYjF6MOdIH7yd1WMeHsSdkqoyXz5Ukzw0joxw3x/Wc9rab7p+jWWl7T9bUxFxZer+g==","signatures":[{"sig":"MEYCIQDV6W6pyr6fqKpamIqyz1YWh1zl/adeRrWzewaHjlyFuQIhAPHSluagm6r+2/HPWT5Jpmzb1Elzb/HrJtvntvC6w04A","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":3675},"main":"src/index.ts","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc"},"_npmUser":{"name":"amruthlp","email":"amruthgowd91200@gmail.com"},"_npmVersion":"10.8.3","directories":{},"_nodeVersion":"21.1.0","_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.6.2","@types/node":"^22.6.1","@types/react":"^18.3.8"},"peerDependencies":{"next":"^14.2.13","react":"^18.3.1"},"_npmOperationalInternal":{"tmp":"tmp/hotkeys_1.0.1_1727161067673_0.22205602234968924","host":"s3://npm-registry-packages"}},"1.1.1":{"name":"@amruthlp/hotkeys","version":"1.1.1","main":"src/index.ts","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc"},"keywords":["hotkeys","shortcuts","nextjs"],"author":{"name":"amruthlp"},"license":"ISC","description":"A simple React component for handling keyboard shortcuts in Next.js applications. It allows you to define custom key combinations and callbacks.","devDependencies":{"@types/node":"^22.6.1","@types/react":"^18.3.8","typescript":"^5.6.2"},"peerDependencies":{"next":"^14.2.13","react":"^18.3.1"},"_id":"@amruthlp/hotkeys@1.1.1","gitHead":"ca250ee117bbf6daafabcb50daaac8619c0f61c8","_nodeVersion":"21.1.0","_npmVersion":"10.8.3","dist":{"integrity":"sha512-CgzDyu3Qpf1+odM+M6OpVJyjCjKFo5wtqaD/sQ1GeM2XA+6fTf0Xj+xX6BJzIYfp33TY7TOgmndmXRTGK5eKjA==","shasum":"3efd23e0b4c5a3a4c7c4d8d8b2ea9dd908c87b3c","tarball":"https://registry.npmjs.org/@amruthlp/hotkeys/-/hotkeys-1.1.1.tgz","fileCount":7,"unpackedSize":6467,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEF5Fy2Oi7y+f3gjV5RbvSoeCA6XijeIDD9NcP149LExAiEAwi0xFkw9LLKRvtlWkGILV6p8WbCn5O694o5r0xiiABQ="}]},"_npmUser":{"name":"amruthlp","email":"amruthgowd91200@gmail.com"},"directories":{},"maintainers":[{"name":"amruthlp","email":"amruthgowd91200@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hotkeys_1.1.1_1727161858665_0.9673127095337775"},"_hasShrinkwrap":false}},"time":{"created":"2024-09-24T06:51:10.420Z","modified":"2024-09-24T07:10:59.016Z","1.0.0":"2024-09-24T06:51:10.741Z","1.0.1":"2024-09-24T06:57:47.874Z","1.1.1":"2024-09-24T07:10:58.840Z"},"license":"ISC","keywords":["hotkeys","shortcuts","nextjs"],"maintainers":[{"name":"amruthlp","email":"amruthgowd91200@gmail.com"}],"readme":"# @amruthlp/hotkeys\r\n\r\nA simple React component for handling keyboard shortcuts in Next.js applications. It allows you to define custom key combinations and callbacks.\r\n\r\n## Installation\r\n\r\nTo use this package, first install it via npm:\r\n\r\n```bash\r\nnpm install @amruthlp/hotkeys \r\n```\r\n\r\n## Usage\r\n\r\n\r\nHere's a simple example of how to use the `HotKeys` component in your Next.js application.\r\n\r\n### Example\r\n\r\n```tsx\r\n'use client';\r\n\r\nimport { useRouter } from \"next/navigation\";\r\nimport { HotKeys } from \"@amruthlp/hotkeys\";\r\n\r\nexport default function Home() {\r\n  const router = useRouter();\r\n\r\n  // Define your keyboard shortcuts\r\n  const shortcuts = [\r\n    {\r\n      keys: [\"ctrl\", \"h\"], // The keys to trigger the action\r\n      callback: () => {\r\n        // This will open the URL in a new tab\r\n        window.open(\"https://www.npmjs.com/package/@amruthlp/hotkeys\", \"_blank\");\r\n      },\r\n    },\r\n  ];\r\n\r\n  return (\r\n    <div>\r\n      <h1>Welcome to the HotKeys Example</h1>\r\n      {/* Use the HotKeys component */}\r\n      <HotKeys shortcuts={shortcuts} />\r\n    </div>\r\n  );\r\n}\r\n```\r\n\r\n### Explanation\r\n\r\n1.  **Import the component**: Import the `HotKeys` component from `@amruthlp/hotkeys`.\r\n2.  **Define your shortcuts**: Create an array of objects, where each object contains:\r\n    -   `keys`: An array of strings representing the keys to trigger the action (e.g., `[\"ctrl\", \"h\"]`).\r\n    -   `callback`: A function that gets executed when the key combination is pressed.\r\n3.  **Open URLs in new tab**: You can use `window.open(URL, \"_blank\")` in the callback to open links in a new tab.\r\n4.  **Wrap in the component**: Use the `HotKeys` component by passing the `shortcuts` array as a prop.\r\n\r\nProps\r\n-----\r\n\r\n-   `shortcuts`: An array of shortcut objects, where each object includes:\r\n    -   `keys`: An array of strings representing the key combination (e.g., `[\"ctrl\", \"k\"]`).\r\n    -   `callback`: A function that gets triggered when the key combination is pressed.\r\n\r\n### Example of Multiple Shortcuts\r\n\r\nYou can also handle multiple shortcuts:\r\n\r\n```tsx\r\nconst shortcuts = [\r\n  {\r\n    keys: [\"ctrl\", \"h\"],\r\n    callback: () => {\r\n      console.log(\"Ctrl + H was pressed\");\r\n    },\r\n  },\r\n  {\r\n    keys: [\"ctrl\", \"s\"],\r\n    callback: () => {\r\n      console.log(\"Ctrl + S was pressed\");\r\n    },\r\n  },\r\n];\r\n\r\n```\r\n\r\nDevelopment\r\n-----------\r\n\r\nTo build and develop this package locally:\r\n\r\n1.  Clone the repository:\r\n\r\n    ```bash\r\n    git clone https://github.com/AmruthLP12/npm-hotkeys.git\r\n    cd npm-hotkeys\r\n    ```\r\n\r\n2.  Install dependencies:\r\n\r\n    ``` bash\r\n    npm install\r\n    ```\r\n\r\n3.  Build the package:\r\n\r\n    ``` bash\r\n    npm run build\r\n    ```\r\n\r\n4.  Publish to npm:\r\n\r\n    ```bash\r\n    npm publish --access public\r\n    ```\r\n\r\n","readmeFilename":"readme.md","description":"A simple React component for handling keyboard shortcuts in Next.js applications. It allows you to define custom key combinations and callbacks.","author":{"name":"amruthlp"}}