javascript/ wii 远程上/下/右/左键作为 TAB
我正在为任天堂 wii 开发一个网站,它以任何方式使用“opera”,我想要的是,在 wii 上浏览任何网站时,我们使用“wii control”。 因此,该控件上有上/下/右/左键,我希望这些键的行为类似于 TAB,因为当您按上/下/右/左键时,它会滚动页面..
注意!!! 对于 TAB,我并不是指在输入字段或文本区域中按 TAB...我想使用该选项卡,就像我们在不使用鼠标时在 PC 上使用选项卡按钮一样
我想知道我是否可以得到一个 javascript 来表示诸如 strat TAB 而不是滚动之类的内容。
document.onkeypress = function(e) { if (e.keyCode == 175 || e.keyCode == 176 || e.keyCode == 178 || e.keyCode == 177) 警报(“按键”); 返回真; 否则如果(e.keyCode == 170 || e.keyCode == 174){ 返回假; } };
谢谢!
I am developing a website for nintendo wii which uses "opera" any ways what i want is that while surfing any website on wii we use "wii control"..
So, the control have up/down/right/left keys on it I want those keys to behave like TAB because when you press up/down/right/left keys it scrolls the page..
Note!!! With the TAB i doesnot mean to TAB in the inputfields or text areas... I want to use the tab as we use on our PC's the tab button while we are not using our mouse
I was wondering if i can get a javascript to say something like strat TAB instead of scroll..
document.onkeypress = function(e) {
if (e.keyCode == 175 || e.keyCode == 176 || e.keyCode == 178 || e.keyCode == 177)
alert("pressing keys");
return true;
else if (e.keyCode == 170 || e.keyCode == 174) {
return false;
}
};
Thanks!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我无法从人机界面的角度推荐您提出的建议,因为这意味着将控件的标准和预期行为完全更改为其他内容。 从用户的角度来看,这是极其令人困惑和令人沮丧的,特别是如果您没有给他们足够合理的警告来期待它。
但是,毫无疑问,您要做的是:
创建一个新的键盘事件:
https://developer.mozilla.org/en/DOM/document.createEvent
初始化事件(使用适当的信息来伪造 Tab 键事件):
https://developer.mozilla.org/en/DOM/event.initKeyEvent
然后调度事件:
https://developer.mozilla.org/en/DOM/element.dispatchEvent
然后将该代码放入上/下/左/右键的事件处理程序中,并从其处理程序中返回 false 以抑制默认行为。
I can't reccomend what you're proposing from a human interface perspective, because it means changing the standard and expected behavior of the controls to something else entirely. This is extremely confusing and frustrating from the user's perspective, especially if you don't give them reasonable enough warning to expect it.
But, giving you the benefit of the doubt, what you'll want to do is:
create a new Keyboard Event:
https://developer.mozilla.org/en/DOM/document.createEvent
initialize the event (with the appropriate information to fake a tab key event):
https://developer.mozilla.org/en/DOM/event.initKeyEvent
and then dispatch the event:
https://developer.mozilla.org/en/DOM/element.dispatchEvent
then put that code into the event handlers for your up/down/left/right keys, and return false from their handlers to suppress the default behavior.