feat(nds): use custom NDS_ keys in events
This commit is contained in:
@@ -51,14 +51,14 @@ export const useButtonNavigation = <T extends Record<string, ButtonConfig>>({
|
||||
}
|
||||
});
|
||||
|
||||
const handleKeyPress = (event: KeyboardEvent) => {
|
||||
useKeyDown((key) => {
|
||||
const currentButton = selectedButton.value as keyof T;
|
||||
const currentNav = navigation[currentButton];
|
||||
|
||||
if (!currentNav) return;
|
||||
|
||||
switch (event.key) {
|
||||
case "ArrowUp":
|
||||
switch (key) {
|
||||
case "NDS_UP":
|
||||
if (!currentNav.up) return;
|
||||
|
||||
if (currentNav.up === "last") {
|
||||
@@ -76,7 +76,7 @@ export const useButtonNavigation = <T extends Record<string, ButtonConfig>>({
|
||||
|
||||
break;
|
||||
|
||||
case "ArrowDown":
|
||||
case "NDS_DOWN":
|
||||
if (!currentNav.down) return;
|
||||
|
||||
if (currentNav.down === "last") {
|
||||
@@ -93,7 +93,7 @@ export const useButtonNavigation = <T extends Record<string, ButtonConfig>>({
|
||||
}
|
||||
break;
|
||||
|
||||
case "ArrowLeft":
|
||||
case "NDS_LEFT":
|
||||
if (!currentNav.left) return;
|
||||
|
||||
if (currentNav.horizontalMode === "preview") {
|
||||
@@ -103,7 +103,7 @@ export const useButtonNavigation = <T extends Record<string, ButtonConfig>>({
|
||||
}
|
||||
break;
|
||||
|
||||
case "ArrowRight":
|
||||
case "NDS_RIGHT":
|
||||
if (!currentNav.right) return;
|
||||
|
||||
if (currentNav.horizontalMode === "preview") {
|
||||
@@ -113,24 +113,13 @@ export const useButtonNavigation = <T extends Record<string, ButtonConfig>>({
|
||||
}
|
||||
break;
|
||||
|
||||
case "Enter":
|
||||
case " ":
|
||||
case "NDS_A":
|
||||
onButtonClick?.(selectedButton.value);
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
window.addEventListener("keydown", handleKeyPress);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener("keydown", handleKeyPress);
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user