Files
directus/app/src/composables/use-shortcut
2020-07-29 11:24:52 -04:00
..
2020-07-29 11:24:52 -04:00
2020-07-29 11:24:52 -04:00
2020-07-29 11:24:52 -04:00

useShortcut

function useShortcut(
	shortcut: string | string[],
	handler: handler: (evt?: ExtendedKeyboardEvent, combo?: string) => void
): void

Can be used to attach a global keyboard shortcut to a function. Removes the shortcut once the current component unmounts

Usage

import { defineComponent } from '@vue/composition-api';
import { useShortcut } from '@/composables/use-shortcut';

export default defineComponent({
	setup(props) {
		useShortcut('mod+s', save);

		function save() {
			// ...
		}
	}
});