Skip to content

Commit 79ae294

Browse files
authored
Merge pull request #90 from PiXeL99-eng/main
Fixed Arrow Up function bug
2 parents ff91923 + 8dc6dc1 commit 79ae294

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

script.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,22 @@ app.addEventListener("keydown", async function (event) {
5656
}
5757
if (event.key === "ArrowUp") {
5858
if (count > 0) {
59+
await delay(0.005);
5960
const input = document.querySelector("input");
6061
input.value = history[--count];
62+
const end = input.value.length;
63+
input.setSelectionRange(end, end);
6164
}
6265
}
6366
if (event.key === "ArrowDown") {
6467
if (count < history.length - 1) {
6568
const input = document.querySelector("input");
6669
input.value = history[++count];
6770
} else {
71+
72+
if (count === history.length - 1){
73+
count++;
74+
}
6875
const input = document.querySelector("input");
6976
input.value = "";
7077
}

0 commit comments

Comments
 (0)