diff --git a/src/App.vue b/src/App.vue index 0a0737b..08ae4e4 100644 --- a/src/App.vue +++ b/src/App.vue @@ -3,6 +3,11 @@ import { dateZhCN, zhCN } from "naive-ui"; import { computed, onMounted, nextTick } from "vue"; import { AppProvider } from "@/components/Application"; import { lighten } from "@/utils/index"; +import mouseTrapBind from '@/hooks/event/mouseTrapBind' + +onMounted(()=>{ + mouseTrapBind(); +}) const getThemeOverrides = computed(() => { const theme = "#1980FF"; diff --git a/src/hooks/event/mouseTrapBind.ts b/src/hooks/event/mouseTrapBind.ts new file mode 100644 index 0000000..b964ae6 --- /dev/null +++ b/src/hooks/event/mouseTrapBind.ts @@ -0,0 +1,14 @@ +import { inject } from 'vue' +const mousetrap = inject('mousetrap') as any +const commonKeyDown = (keyCode: number) => { + document.dispatchEvent(new KeyboardEvent('keydown', { keyCode })); +} +const c = () => { + commonKeyDown(27) +} + +const initBind = () => { + mousetrap.bind('c', c) +} + +export default initBind; \ No newline at end of file