使用Javascript进行键映射 [英] key Mapping using Javascript
本文介绍了使用Javascript进行键映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试使用JS进行键映射.
当前选项卡用于将网页中的一个选项卡移至另一选项卡.
我想使用箭头键(上,下,左,右)做同样的事情.
如果我按向上箭头键,控件将移至上方的Htmlcontrol(如文本框单选按钮等).
如果按向下箭头键,控件将向下移至Htmlcontrol.
与左右相同...
请
帮帮我!..
I am try to do the Key mapping using JS.
currently tab is used to move one tab to other in web page.
same thing I want to do using arrow (up,down,left,right) key.
If I press up arrow key control will move to upper Htmlcontrol(like textbox radiobutton etc).
If I press down arrow key Control will move to down Htmlcontrol.
same as left and right...
Please
Help me!..
推荐答案
先生,我认为您需要处理这些控件的onkeydown
事件.您可以通过以下代码获取密钥代码:
Sir, I think you need to handleonkeydown
events for these controls. you can obtain keycode by the code:
var evt = (window.event) ? event : null;
if (evt) {
var charCode = (evt.charCode) ?
evt.charCode :
((evt.keyCode) ? evt.keyCode :
((evt.which) ? evt.which : 0));
}
您还可以使用此页面来测试关键代码.
you can also use this page to test key codes.
这篇关于使用Javascript进行键映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文