Does anyone know why the onkeydown()
event does not work for delete and backspace key in IE? It works fine for number and character keys.
Asked
Active
Viewed 2,676 times
0

Brian Tompsett - 汤莱恩
- 5,753
- 72
- 57
- 129

Jin Yong
- 42,698
- 72
- 141
- 187
-
see also http://stackoverflow.com/questions/664631/disable-backspace-and-delete-key-with-javascript-in-ie – derobert Mar 20 '09 at 04:31
-
Which version of IE are you testing against? – Jaime Garcia Mar 22 '09 at 00:08
1 Answers
0
Are you sure? .. the following sees delete and backspace fine on IE:
<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>

Scott Evernden
- 39,136
- 15
- 78
- 84
-
yes, not sure why this is not call to the function at all if pressing backspace or delete – Jin Yong Mar 20 '09 at 04:49