parent
a7fa0cb98f
commit
682063c263
@ -0,0 +1,14 @@
|
|||||||
|
import { inject, onMounted, onUnmounted, ref } from "vue"
|
||||||
|
|
||||||
|
export const useKeydown = (key,handler) => {
|
||||||
|
const mousetrap = inject('mousetrap') as any
|
||||||
|
const event = ref()
|
||||||
|
onMounted(() => {
|
||||||
|
event.value = mousetrap.bind(key, handler)
|
||||||
|
|
||||||
|
})
|
||||||
|
onUnmounted(() => {
|
||||||
|
event.value.unbind(key, handler)
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue