|
39 | 39 | align-items: center; |
40 | 40 | background-color: var(--background-color); |
41 | 41 | min-height: 100vh; |
42 | | - padding-bottom: 250px; /* 為鍵盤預留空間 */ |
| 42 | + /* 調整 padding-bottom 以容納多一行的數字鍵 */ |
| 43 | + padding-bottom: 280px; |
43 | 44 | } |
44 | 45 |
|
45 | 46 | /* ------------------ 頂部區域 ------------------ */ |
|
230 | 231 | <div id="main-input">編碼顯示在此</div> |
231 | 232 | <div id="candidate-display">候選字顯示在此...</div> |
232 | 233 | </div> |
233 | | - |
234 | | - </div> |
| 234 | + </div> |
235 | 235 |
|
236 | 236 | <div class="keyboard-container" id="keyboard-container"> |
237 | 237 | </div> |
|
247 | 247 | 'h': 'H', 'i': 'I', 'j': 'J', 'k': 'K', 'l': 'L', 'm': 'M', 'n': 'N', |
248 | 248 | 'o': 'O', 'p': 'P', 'q': 'Q', 'r': 'R', 's': 'S', 't': 'T', 'u': 'U', |
249 | 249 | 'v': 'V', 'w': 'W', 'x': 'X', 'y': 'Y', 'z': 'Z', |
250 | | - // 符號對應 |
| 250 | + // 數字與符號對應 (按鍵顯示) |
| 251 | + '1': '1', '2': '2', '3': '3', '4': '4', '5': '5', |
| 252 | + '6': '6', '7': '7', '8': '8', '9': '9', '0': '0', |
251 | 253 | "'": "〃", ';': ';', ',': ',', '.': '.', '/': '/', ' ': '空白鍵', 'enter': 'Enter', 'backspace': '刪除鍵', |
252 | | - 'shift': '三碼', // *** 修正: 中文模式顯示 '三碼' |
| 254 | + 'shift': '三碼', |
253 | 255 | }; |
254 | 256 | // 英文模式下的鍵盤顯示 (Shift 鍵顯示為 'En') |
255 | 257 | const keyname_map_lower = { |
256 | 258 | 'a': 'a', 'b': 'b', 'c': 'c', 'd': 'd', 'e': 'e', 'f': 'f', 'g': 'g', |
257 | 259 | 'h': 'h', 'i': 'i', 'j': 'j', 'k': 'k', 'l': 'l', 'm': 'm', 'n': 'n', |
258 | 260 | 'o': 'o', 'p': 'p', 'q': 'q', 'r': 'r', 's': 's', 't': 't', 'u': 'u', |
259 | 261 | 'v': 'v', 'w': 'w', 'x': 'x', 'y': 'y', 'z': 'z', |
| 262 | + // 數字與符號對應 |
| 263 | + '1': '1', '2': '2', '3': '3', '4': '4', '5': '5', |
| 264 | + '6': '6', '7': '7', '8': '8', '9': '9', '0': '0', |
260 | 265 | "'": "'", ';': ';', ',': ',', '.': '.', '/': '/', ' ': ' ', 'enter': 'Enter', 'backspace': '刪除鍵', |
261 | | - 'shift': 'En', // *** 修正: 英文模式顯示 'En' |
| 266 | + 'shift': 'En', |
262 | 267 | }; |
263 | 268 |
|
264 | 269 | // DOM 元素 |
265 | 270 | const textOutput = document.getElementById('text-output'); |
266 | 271 | const mainInput = document.getElementById('main-input'); |
267 | 272 | const candidateDisplay = document.getElementById('candidate-display'); |
268 | 273 | const keyboardContainer = document.getElementById('keyboard-container'); |
269 | | - // const modeDisplay = document.getElementById('mode-display'); // 已移除 |
270 | 274 | const copyButton = document.getElementById('copy-btn'); |
271 | 275 | const clearButton = document.getElementById('clear-btn'); |
272 | 276 |
|
|
311 | 315 | const { newCodemap, newReverseCodemap } = parseCinData(text); |
312 | 316 | currentCodemap = newCodemap; |
313 | 317 | currentReverseCodemap = newReverseCodemap; |
314 | | - // updateModeDisplay(); // 已移除 |
315 | 318 | mainInput.textContent = '編碼表載入成功'; |
316 | 319 | } catch (error) { |
317 | 320 | console.error(`載入 ${fileName} 時發生錯誤:`, error); |
|
322 | 325 |
|
323 | 326 | // --- 處理中文模式輸入的核心函數 --- |
324 | 327 | function handleChineseInput(code) { |
325 | | - // 忽略數字鍵 |
326 | | - if (code.match(/^[1-90]$/)) { |
| 328 | + const inputChar = code.toLowerCase(); |
| 329 | + |
| 330 | + // 1. 數字鍵處理 (直接輸出半形數字) |
| 331 | + if (inputChar.match(/^[0-9]$/)) { |
| 332 | + if (currentCandidates.length > 0) { |
| 333 | + selectCandidate(0); // 如果有編碼,先上字 |
| 334 | + } |
| 335 | + textOutput.textContent += inputChar; // 直接輸出數字 |
327 | 336 | return; |
328 | 337 | } |
329 | 338 |
|
|
354 | 363 | return; |
355 | 364 | } |
356 | 365 |
|
357 | | - const inputChar = code.toLowerCase(); |
358 | | - // 接受所有 26 字母和 5 符號的輸入 |
| 366 | + // 2. 字母 (a-z) 和符號 (;'./,) 用於編碼 |
359 | 367 | if (inputChar.match(/^[a-z;'./,<>]$/)) { |
360 | 368 | if (currentCode.length === MAX_CODE_LENGTH) { |
361 | 369 | if (currentCandidates.length > 0) { |
|
387 | 395 | return; |
388 | 396 | } |
389 | 397 |
|
390 | | - // 處理英文字母和符號 |
| 398 | + // 處理英文字母、數字和符號 |
391 | 399 | if (char.length === 1) { |
392 | 400 | textOutput.textContent += char; |
393 | 401 | } |
|
460 | 468 | return displayString; |
461 | 469 | } |
462 | 470 |
|
463 | | - // --- 更新鍵盤按鍵顯示 (專門處理 Shift 鍵的變動) --- |
| 471 | + // --- 更新鍵盤按鍵顯示 --- |
464 | 472 | function updateKeyboardDisplay() { |
465 | 473 | const map = isEnglishMode ? keyname_map_lower : keyname_map_upper; |
466 | 474 | document.querySelectorAll('.key[data-code]').forEach(keyElement => { |
|
470 | 478 | } |
471 | 479 | }); |
472 | 480 |
|
473 | | - // 確保 Shift 鍵在模式切換時正確顯示 |
474 | 481 | const shiftKey = document.querySelector('.key[data-code="shift"]'); |
475 | 482 | if (shiftKey) { |
476 | 483 | shiftKey.textContent = isEnglishMode ? keyname_map_lower['shift'] : keyname_map_upper['shift']; |
477 | 484 | } |
478 | 485 | } |
479 | 486 |
|
480 | | - // --- 動態生成手機優化鍵盤 --- |
| 487 | + // --- 動態生成手機優化鍵盤 (新增數字行) --- |
481 | 488 | function generateMobileKeyboard() { |
482 | 489 | const layout_mobile = [ |
| 490 | + ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'], // 新增數字行 |
483 | 491 | ['Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P'], |
484 | 492 | ['A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ';'], |
485 | 493 | ['Z', 'X', 'C', 'V', 'B', 'N', 'M', ',', '.', '/', "'"], |
|
514 | 522 | } |
515 | 523 |
|
516 | 524 | key.dataset.code = code; |
517 | | - // 初始顯示為中文模式 ('三碼') |
518 | 525 | key.textContent = keyname_map_upper[code] || keyText; |
519 | 526 |
|
520 | 527 | key.addEventListener('click', () => { |
521 | 528 | if (code === 'shift') { |
522 | 529 | isEnglishMode = !isEnglishMode; |
523 | | - // updateModeDisplay(); // 已移除 |
524 | 530 | updateKeyboardDisplay(); |
525 | 531 | resetInputState(); |
526 | 532 | } else if (isEnglishMode) { |
|
0 commit comments