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>
Reactions

Post a Comment

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

Please do not post any spam link in the comment box😊

Emoji
(y)
:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
:>)
(o)
:p
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
x-)
(k)

Close Menu