Entry
How to trap backspace button event and trap it if the focus is in not inside a text field /text area
Jun 27th, 2003 09:27
Kasey, Mohan B,
You can trap the backspace button using this short piece of code.
<script type="text/JavaScript" language="JavaScript">
<!--
function disablebackspace() {
if (window.focus) window.focus();
document.onkeydown=catchbackspace;
document.onkeyup=catchbackspace;
}
function catchbackspace() {
if (!e) e=window.event;
if (e.keyCode==8){
alert("Backspace key was pressed.");
return false;
}
}
// -->
</script>
Good luck!