Vue composition for using keyboard shortcuts in components. This is a hook version for hotkeys package.
via pnpm, yarn or npm:
$ pnpm add vue-use-hotkeys
# or
$ yarn add vue-use-hotkeys
# or
$ npm i -S vue-use-hotkeys
import { defineComponent, ref } from 'vue'
import { useHotkeys } from 'vue-use-hotkeys'
export default defineComponent(() => {
const count = ref(0)
useHotkeys('ctrl + k', () => {
count.value += 1
})
return () => (
<p>
Pressed <kbd>ctrl + k</kbd> {count.value} times.
</p>
)
})
Preview demo:
- add support of
@vue/composition-api
;
MIT © Mitscherlich