eefd7abf83
Reorganize components into category folders (forms/canvas/overlays/etc.); add the media-editor headless family (timeline, curve-editor, waveform, crop, color picker, etc.); apply perf fixes (O(1) collection lookups, plain-object drag state, gesture-leak teardown, shallowRef color state, rect caching) and replace source `any` with proper types.
24 lines
645 B
TypeScript
24 lines
645 B
TypeScript
import { ref } from 'vue';
|
|
|
|
const isUsingKeyboard = ref(false);
|
|
let initialized = false;
|
|
|
|
function init() {
|
|
if (initialized || typeof document === 'undefined') return;
|
|
initialized = true;
|
|
document.addEventListener('keydown', () => {
|
|
isUsingKeyboard.value = true;
|
|
}, { capture: true, passive: true });
|
|
document.addEventListener('pointerdown', () => {
|
|
isUsingKeyboard.value = false;
|
|
}, { capture: true, passive: true });
|
|
document.addEventListener('pointermove', () => {
|
|
isUsingKeyboard.value = false;
|
|
}, { capture: true, passive: true });
|
|
}
|
|
|
|
export function useIsUsingKeyboard() {
|
|
init();
|
|
return isUsingKeyboard;
|
|
}
|