Files
pihkaal-me/app/utils/input.ts
Pihkaal f4ebe93135
All checks were successful
Build and Push Docker Image / build (push) Successful in 2m31s
feat(nds): use key codes instead of keys to handle multiple layouts
2026-02-16 13:57:26 +01:00

27 lines
557 B
TypeScript

const CODE_TO_NDS_BUTTON: Record<string, string> = {
ArrowUp: "UP",
ArrowDown: "DOWN",
ArrowLeft: "LEFT",
ArrowRight: "RIGHT",
KeyD: "A",
KeyS: "B",
KeyW: "X",
KeyA: "Y",
Space: "SELECT",
Enter: "START",
};
export const mapCodeToNDS = (code: string): string | null => {
return CODE_TO_NDS_BUTTON[code] ?? null;
};
export const useMouseUp = (callback: () => void) => {
onMounted(() => {
document.addEventListener("mouseup", callback);
});
onUnmounted(() => {
document.removeEventListener("mouseup", callback);
});
};