Wednesday, January 16, 2008

Restrict User From Ctrl Key Press

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Restrict Ctrl Key Press</title>

    <script>
        function Restrict() {
            if ((window.event.keyCode == 17)) {
                alert("Ctrl Key Press In !" + '\r\n' + "Add Your Own Code Here"); // Add Your Code Here
            }
        }
    </script>

</head>
<body onload="JavaScript:document.body.focus();" onkeydown="Restrict()">
</body>
</html>

2 comments:

  1. Hi Varanasi
    Current code only works in IE.
    Check this code
    document.onkeydown = Restrict;
    function Restrict(e) {
    if (!e)
    var e = window.event;

    key = e.keyCode;

    alert("Ctrl Key Press In !" + '\r\n' + "Add Your Own Code Here"); // Add Your Code Here
    }

    it's working fine in IE and mozila
    Thanks,
    Santosh

    ReplyDelete