导读:
写了下面一段HTML代码:
然后在文本框中不断的测试输入,得到一下结果,很有参考价值。
输入 结果
a 12a3
7 1273
tab 1
enter 123
ctrl 13
shift 13
alt 13
* 12*3
上箭头 13
有1代表触发了onkeydonw事件,有2代表触发了onkeypress事件,有3说明出发了onkeyup事件。
有一点说明:按下tab键后,不是不触发keyup事件,而是转到下一个输入框去触发onkeyup事件。
写了下面一段HTML代码:
<
head
>
< meta http-equiv ="Content-Type" content ="text/html; charset=gb2312" />
< title > 无标题文档 </ title >
< script type ="text/javascript" > ...
function keydown()...{
var aa=document.getElementById("t");
aa.value = 1;
return false;
}
function keypress()...{
var aa=document.getElementById("t");
aa.value = aa.value + 2;
}
function keyup()...{
var aa=document.getElementById("t");
aa.value = aa.value + 3;
}
</ script >
</ head >
< body >
< input type ="text" id ="t" onkeydown ="keydown()" onkeypress ="keypress()" onkeyup ="keyup()" />
</ body >
</ html >
< meta http-equiv ="Content-Type" content ="text/html; charset=gb2312" />
< title > 无标题文档 </ title >
< script type ="text/javascript" > ...
function keydown()...{
var aa=document.getElementById("t");
aa.value = 1;
return false;
}
function keypress()...{
var aa=document.getElementById("t");
aa.value = aa.value + 2;
}
function keyup()...{
var aa=document.getElementById("t");
aa.value = aa.value + 3;
}
</ script >
</ head >
< body >
< input type ="text" id ="t" onkeydown ="keydown()" onkeypress ="keypress()" onkeyup ="keyup()" />
</ body >
</ html >
然后在文本框中不断的测试输入,得到一下结果,很有参考价值。
输入 结果
a 12a3
7 1273
tab 1
enter 123
ctrl 13
shift 13
alt 13
* 12*3
上箭头 13
有1代表触发了onkeydonw事件,有2代表触发了onkeypress事件,有3说明出发了onkeyup事件。
有一点说明:按下tab键后,不是不触发keyup事件,而是转到下一个输入框去触发onkeyup事件。