繁体   English   中英

Onkeydown() 不适用于 IE 中的删除和退格

[英]Onkeydown() does not work for delete and backspace in IE

有谁知道为什么onkeydown()事件不适用于 IE 中的删除退格键? 它适用于数字和字符键。

你确定吗? .. 以下在 IE 上看到 delete 和 backspace 很好:

<html>
<head>
<script type="text/javascript">
function keypress(e)
{
    var keycode;
    if (window.event) // IE
    {
        keycode = e.keyCode;
    }
    else if (e.which) // Netscape/FF/Op
    {
        keycode = e.which;
    }
    alert(keycode);
}
</script>
</head>
<body>
<form>
    <input type="text" onkeydown="return keypress(event)" />
</form>
</body>
</html> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM