2016-11-24 24 views
3

我一直在開發智能電視的tizen網絡應用程序
有一個視圖,我有很多輸入,所以我需要設置它們之間的導航,實際上導航還有像的div和圖片等元素,但一旦我是一個輸入(聚焦狀態)內我不能移動到任何其他元素 此功能工作的事件監聽器函數如何調用輸入內的關鍵事件

document.addEventListener('keydown',function(e) { 
       switch (e.keyCode) { 
       case TvKeyCode.KEY_LEFT: 
        navigation("left"); 
        break; 
       case TvKeyCode.KEY_UP: 
        navigation("up"); 
        break; 
       case TvKeyCode.KEY_RIGHT: 
        navigation("right"); 
        break; 
       case TvKeyCode.KEY_DOWN:      
        navigation("down"); 
        break; 
       case TvKeyCode.KEY_ENTER: 
        break; 
       } 
}); 

這裏的導航功能(inputindex已經被初始化爲零)

function navigation(direction) { 
    if (direction == "up") { 
     $(".bottom-container").find("input").filter('input:eq('+inputindex+')').focus(); 
     inputindex--; 
     } 
    if (direction == "down") { 
     $(".bottom-container").find("input").filter('input:eq('+inputindex+')').focus(); 
     inputindex++; 
     } 

    if (direction == "left") { 
     //an other fnction 
     } 
    if (direction == "right") { 
     //an other function 
     } 
} 

這裏的輸入

<tr> 
       <td>Math:</td> 
       <td><input class="inputsize" type="number" size="4" 
        max="20" step="0" /></td> 
       <td><input class="inputsize" type="number" size="4" 
        max="20" step="0" /></td> 
      </tr> 
      <tr> 
       <td>Science:</td> 
       <td><input class="inputsize" type="number" size="4" 
        max="20" step="0" /></td> 
       <td><input class="inputsize" type="number" size="4" 
        max="20" step="0" /></td> 
      </tr> 

任何幫助,請

+0

你有輸入事件監聽器嗎? – nottu

+0

我想沒有它只是一個簡單的 –

回答

1

添加了 '輸入設備' 特權config.xml文件

<tizen:privilege name="http://tizen.org/privilege/tv.inputdevice"/> 

您可以沿着檢查這個Text input GuideKey codeSample code

相關問題