Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am developing an on-line exam portal and need help to disable the ctrl key

Please provide me the needful help so the content on the website will not be able to be copy and get distributed.
Posted
Updated 29-Oct-13 1:18am
v4
Comments
ZurdoDev 26-Oct-13 8:55am    
Just google for example. You'll likely get faster response that way.
Sergey Alexandrovich Kryukov 17-Feb-14 17:16pm    
The question makes no sense as you did not specify what is the application type, UI library/framework you are using, etc. Always add proper tags to your question.
—SA

You CANNOT really protect your website from being copied/distributed: you can use JavaScript as you can see in the other answers, but someone can simply disabling JavaScript, or installing an extension that disables it. Someone can also copy the source code of your page (or simply saving it by pressing Ctrl+S), or someone can take a screenshot of your page and distributing the screenshot.

So, unfortunately, you can't.
 
Share this answer
 
In your page body tag you simply need to "return flase" for below mentioned JavaScript functions

<body ondragstart="return false;" onselectstart="return false;" oncontextmenu="return false;" >
 
Share this answer
 
v2
For disabling right-click you can use.
JavaScript
<script language="javascript">
    document.onmousedown=disableclick;
    status="Right Click Disabled";
    Function disableclick(event)
    {
      if(event.button==2)
       {
         alert(status);
         return false;    
       }
    }
    </script>

and put this code on body like this
HTML
<body oncontextmenu="return false">
    ...
    </body>

and for disable copy content from page
JavaScript
<script language="JavaScript1.2">
    var msgpopup="COPYING CONTENT IS PROHIBITED";
    function handle(){
          if(toShowMessage== "1") alert(message);
              if(closeSelf== "1") self.close();
              return false;
    }
    function mouseDown() {
         if (event.button == "2" || event.button == "3"){handle();}
    }
    function mouseUp(e) {
         //if (document.layers || (document.getElementById && !document.all)){
              if (e.which == "2" || e.which == "3"){ handle();}
         //}
    }
    document.onmousedown=mouseDown;
    document.onmouseup=mouseUp;
    document.oncontextmenu=new Function("alert(msgpopup);return false")
    </script>
 
Share this answer
 
v3
Comments
durgesh j 27-Oct-13 3:34am    
Combine solution bcz control key disable function is not working
Sergey Alexandrovich Kryukov 17-Feb-14 17:17pm    
Look, have some shame, stop posting your totally fake answers, before it went too far. It does not even related to C# OP asked about.
It's way to easy to report for abuse which can lead to cancellation of your CodeProject account.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900