File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments