我一直在为智能电视开发一个 tizen 网络应用程序
有一个 View ,我有很多输入,所以我需要在它们之间设置导航,事实上,导航功能适用于其他元素,如 div 和图片,但是一旦我进入输入(onfocus),我就无法移动到任何其他元素元素
这是事件监听器函数
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已经初始化为0)
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>
请帮忙
最佳答案
在您的 config.xml 文件中添加“输入设备”权限
<tizen:privilege name="http://tizen.org/privilege/tv.inputdevice"/>
你可以查看这个Text input Guide和 Key code连同 Sample code .
关于javascript - 我怎样才能在输入中调用按键事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40776814/