|
300 | 300 | color: red; |
301 | 301 | } |
302 | 302 |
|
| 303 | + /* 焦點高亮顯示 */ |
| 304 | + .focused-char-background { |
| 305 | + background-color: #c5cae9 !important; /* 使用較明顯的藍色調 */ |
| 306 | + border-radius: 4px; |
| 307 | + } |
| 308 | + |
303 | 309 | /* 鍵盤樣式 */ |
304 | 310 | .keyboard-container { |
305 | 311 | width: 100%; |
@@ -1044,6 +1050,11 @@ <h2>查碼練習</h2> |
1044 | 1050 | } |
1045 | 1051 | } |
1046 | 1052 |
|
| 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 | + |
1047 | 1058 | const encodingContainer = document.createElement('div'); |
1048 | 1059 | encodingContainer.style.display = 'flex'; |
1049 | 1060 | encodingContainer.style.flexDirection = 'column'; |
@@ -1095,13 +1106,14 @@ <h2>查碼練習</h2> |
1095 | 1106 | } |
1096 | 1107 |
|
1097 | 1108 | 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 |
1100 | 1111 |
|
1101 | 1112 | 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 |
1104 | 1115 |
|
| 1116 | + // 頁面載入時先初始化顯示 |
1105 | 1117 | switchInputMethod('primary'); |
1106 | 1118 | updateKeyboardDisplay(); |
1107 | 1119 | </script> |
|
0 commit comments