Skip to content

Commit 6ec2ffa

Browse files
authored
Update test.html
1 parent 9769dc0 commit 6ec2ffa

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

test.html

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -564,12 +564,23 @@ <h2>輸入法模式:</h2>
564564
keyElement.classList.add('active');
565565
}
566566

567-
// 處理數字選字
568-
if (event.key >= '1' && event.key <= '9') {
569-
const selectedIndex = parseInt(event.key) - 1;
570-
if (selectedIndex < candidates.length) {
571-
textOutput.textContent += candidates[selectedIndex];
572-
resetInputState();
567+
// 處理數字選字或直接上字
568+
if (event.key >= '0' && event.key <= '9') {
569+
if (candidates.length > 0) {
570+
const selectedIndex = parseInt(event.key === '0' ? '9' : event.key) - 1; // '0' for 10th candidate
571+
if (event.key === '0') {
572+
if (candidates.length > 9) {
573+
textOutput.textContent += candidates[9];
574+
resetInputState();
575+
}
576+
} else {
577+
if (selectedIndex < candidates.length) {
578+
textOutput.textContent += candidates[selectedIndex];
579+
resetInputState();
580+
}
581+
}
582+
} else {
583+
textOutput.textContent += event.key;
573584
}
574585
return;
575586
}

0 commit comments

Comments
 (0)