feat: add v-shortcut directive for keyboard shortcuts (#942)
Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/942 Reviewed-by: dpschen <dpschen@noreply.kolaente.de> Co-authored-by: konrad <k@knt.li> Co-committed-by: konrad <k@knt.li>
This commit is contained in:
17
src/directives/shortcut.ts
Normal file
17
src/directives/shortcut.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import {Directive} from 'vue'
|
||||
import {install, uninstall} from '@github/hotkey'
|
||||
import {isAppleDevice} from '@/helpers/isAppleDevice'
|
||||
|
||||
const directive: Directive = {
|
||||
mounted(el, {value}) {
|
||||
if (isAppleDevice() && value.includes('Control')) {
|
||||
value = value.replace('Control', 'Meta')
|
||||
}
|
||||
install(el, value)
|
||||
},
|
||||
beforeUnmount(el) {
|
||||
uninstall(el)
|
||||
},
|
||||
}
|
||||
|
||||
export default directive
|
Reference in New Issue
Block a user