Files
pihkaal-me/app/composables/useKeyUp.ts
2025-12-14 18:58:22 +01:00

16 lines
351 B
TypeScript

export type KeyUpCallback = (key: string) => void;
export const useKeyUp = (callback: KeyUpCallback) => {
const handleKeyUp = (event: KeyboardEvent) => {
callback(event.key);
};
onMounted(() => {
window.addEventListener("keyup", handleKeyUp);
});
onUnmounted(() => {
window.removeEventListener("keyup", handleKeyUp);
});
};