feat(nds): improve key input system

This commit is contained in:
2026-02-10 16:28:54 +01:00
parent a586c149d8
commit 14b9ee6119
16 changed files with 59 additions and 102 deletions

View File

@@ -1,8 +1,19 @@
export type KeyDownCallback = (key: string) => void;
import { mapKeyToNDS } from "~/utils/input";
export type KeyDownCallback = (params: {
key: string;
ndsButton: string | null;
repeated: boolean;
}) => void;
export const useKeyDown = (callback: KeyDownCallback) => {
const handleKeyDown = (event: KeyboardEvent) => {
callback(event.key);
const ndsButton = mapKeyToNDS(event.key);
callback({
key: ndsButton ? `NDS_${ndsButton}` : event.key,
ndsButton,
repeated: event.repeat,
});
};
onMounted(() => {