Skip to content

Commit 7663b32

Browse files
authored
Add files via upload
1 parent e996ab9 commit 7663b32

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

test.html

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,12 @@
300300
color: red;
301301
}
302302

303+
/* 焦點高亮顯示 */
304+
.focused-char-background {
305+
background-color: #c5cae9 !important; /* 使用較明顯的藍色調 */
306+
border-radius: 4px;
307+
}
308+
303309
/* 鍵盤樣式 */
304310
.keyboard-container {
305311
width: 100%;
@@ -1044,6 +1050,11 @@ <h2>查碼練習</h2>
10441050
}
10451051
}
10461052

1053+
// Add the highlighted background for the character corresponding to the cursor
1054+
if (i < characters.length && (lookupStartIndex + i) === cursorPosition) {
1055+
charLabel.classList.add('focused-char-background');
1056+
}
1057+
10471058
const encodingContainer = document.createElement('div');
10481059
encodingContainer.style.display = 'flex';
10491060
encodingContainer.style.flexDirection = 'column';
@@ -1095,13 +1106,14 @@ <h2>查碼練習</h2>
10951106
}
10961107

10971108
phraseInput.addEventListener('input', updatePhraseLookup);
1098-
phraseInput.addEventListener('keyup', updatePhraseLookup);
1099-
phraseInput.addEventListener('click', updatePhraseLookup);
1109+
phraseInput.addEventListener('keyup', updatePhraseLookup); // Capture key releases for cursor movement
1110+
phraseInput.addEventListener('click', updatePhraseLookup); // Capture mouse clicks for cursor movement
11001111

11011112
textOutput.addEventListener('input', updatePhraseLookup);
1102-
textOutput.addEventListener('keyup', updatePhraseLookup);
1103-
textOutput.addEventListener('click', updatePhraseLookup);
1113+
textOutput.addEventListener('keyup', updatePhraseLookup); // Capture key releases for cursor movement
1114+
textOutput.addEventListener('click', updatePhraseLookup); // Capture mouse clicks for cursor movement
11041115

1116+
// 頁面載入時先初始化顯示
11051117
switchInputMethod('primary');
11061118
updateKeyboardDisplay();
11071119
</script>

0 commit comments

Comments
 (0)