Skip to content

Commit 96d04cd

Browse files
committed
yeah didnt think so, the other part is NICE tho
1 parent e1eb85f commit 96d04cd

File tree

1 file changed

+10
-31
lines changed

1 file changed

+10
-31
lines changed

assets/js/mud-overlay.js

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -947,10 +947,7 @@
947947
});
948948

949949
// Arrow key navigation state
950-
let lastKeyPress = null;
951-
let lastKeyTime = 0;
952950
let lastActionTime = 0;
953-
const DOUBLE_TAP_WINDOW = 300; // ms to detect double tap
954951
const ACTION_COOLDOWN = 1000; // ms between actions
955952

956953
const sendDirection = (direction) => {
@@ -1007,47 +1004,29 @@
10071004
}
10081005
});
10091006

1010-
// Global arrow key listener for directional movement (when input not focused)
1007+
// Global key listener for directional movement (when input not focused)
10111008
document.addEventListener("keydown", (e) => {
1012-
// Only handle arrows when input is not focused
1009+
// Only handle navigation when input is not focused
10131010
if (document.activeElement === input) return;
1014-
if (!e.key.startsWith("Arrow")) return;
1015-
1016-
const now = Date.now();
1017-
const timeSinceLastKey = now - lastKeyTime;
10181011

10191012
if (e.key === "ArrowUp") {
10201013
e.preventDefault();
1021-
// Check for double-tap
1022-
if (lastKeyPress === "ArrowUp" && timeSinceLastKey < DOUBLE_TAP_WINDOW) {
1023-
sendDirection("n"); // double-tap = up/north shorthand
1024-
lastKeyPress = null; // Reset to prevent triple-taps
1025-
} else {
1026-
sendDirection("north");
1027-
lastKeyPress = "ArrowUp";
1028-
}
1029-
lastKeyTime = now;
1014+
sendDirection("north");
10301015
} else if (e.key === "ArrowDown") {
10311016
e.preventDefault();
1032-
// Check for double-tap
1033-
if (lastKeyPress === "ArrowDown" && timeSinceLastKey < DOUBLE_TAP_WINDOW) {
1034-
sendDirection("s"); // double-tap = down/south shorthand
1035-
lastKeyPress = null; // Reset to prevent triple-taps
1036-
} else {
1037-
sendDirection("south");
1038-
lastKeyPress = "ArrowDown";
1039-
}
1040-
lastKeyTime = now;
1017+
sendDirection("south");
10411018
} else if (e.key === "ArrowLeft") {
10421019
e.preventDefault();
10431020
sendDirection("west");
1044-
lastKeyPress = "ArrowLeft";
1045-
lastKeyTime = now;
10461021
} else if (e.key === "ArrowRight") {
10471022
e.preventDefault();
10481023
sendDirection("east");
1049-
lastKeyPress = "ArrowRight";
1050-
lastKeyTime = now;
1024+
} else if (e.key === "u" || e.key === "U") {
1025+
e.preventDefault();
1026+
sendDirection("u");
1027+
} else if (e.key === "d" || e.key === "D") {
1028+
e.preventDefault();
1029+
sendDirection("d");
10511030
}
10521031
});
10531032

0 commit comments

Comments
 (0)