简体   繁体   English

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

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

Does anyone know why the onkeydown() event does not work for delete and backspace key in IE?有谁知道为什么onkeydown()事件不适用于 IE 中的删除退格键? It works fine for number and character keys.它适用于数字和字符键。

Are you sure?你确定吗? .. the following sees delete and backspace fine on 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