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);
  });
};
