Hi ,
Just copy and paste this code and save your file.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Disable Ctrl Key, Right click and F12 </title>
<script language="JavaScript">
//////////F12 disable code////////////////////////
document.onkeypress = function (event) {
event = (event || window.event);
if (event.keyCode == 123) {
//alert('No F-12');
return false;
}
}
document.onmousedown = function (event) {
event = (event || window.event);
if (event.keyCode == 123) {
//alert('No F-keys');
return false;
}
}
document.onkeydown = function (event) {
event = (event || window.event);
if (event.keyCode == 123) {
//alert('No F-keys');
return false;
}
}
/////////////////////end///////////////////////
//Disable right click script
//visit http://www.rainbow.arch.scriptmania.com/scripts/
var message="Sorry, right-click has been disabled";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")
//
function disableCtrlKeyCombination(e)
{
//list all CTRL + key combinations you want to disable
var forbiddenKeys = new Array('a', 'n', 'c', 'x', 'v', 'j' , 'w');
var key;
var isCtrl;
if(window.event)
{
key = window.event.keyCode; //IE
if(window.event.ctrlKey)
isCtrl = true;
else
isCtrl = false;
}
else
{
key = e.which; //firefox
if(e.ctrlKey)
isCtrl = true;
else
isCtrl = false;
}
//if ctrl is pressed check if other key is in forbidenKeys array
if(isCtrl)
{
for(i=0; i<forbiddenKeys.length; i++)
{
//case-insensitive comparation
if(forbiddenKeys[i].toLowerCase() == String.fromCharCode(key).toLowerCase())
{
alert('Key combination CTRL + '+String.fromCharCode(key) +' has been disabled.');
return false;
}
}
}
return true;
}
</script>
</head>
<body onkeypress="return disableCtrlKeyCombination(event);" onkeydown="return disableCtrlKeyCombination(event);">
Press ctrl and you can check various key is disable with CTRL. like — 'a', 'n', 'c', 'x', 'v', 'j' , 'w' Just add key in above the array and disable key as you want.
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Disable Ctrl Key, Right click and F12 </title>
<script language="JavaScript">
//////////F12 disable code////////////////////////
document.onkeypress = function (event) {
event = (event || window.event);
if (event.keyCode == 123) {
//alert('No F-12');
return false;
}
}
document.onmousedown = function (event) {
event = (event || window.event);
if (event.keyCode == 123) {
//alert('No F-keys');
return false;
}
}
document.onkeydown = function (event) {
event = (event || window.event);
if (event.keyCode == 123) {
//alert('No F-keys');
return false;
}
}
/////////////////////end///////////////////////
//Disable right click script
//visit http://www.rainbow.arch.scriptmania.com/scripts/
var message="Sorry, right-click has been disabled";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")
//
function disableCtrlKeyCombination(e)
{
//list all CTRL + key combinations you want to disable
var forbiddenKeys = new Array('a', 'n', 'c', 'x', 'v', 'j' , 'w');
var key;
var isCtrl;
if(window.event)
{
key = window.event.keyCode; //IE
if(window.event.ctrlKey)
isCtrl = true;
else
isCtrl = false;
}
else
{
key = e.which; //firefox
if(e.ctrlKey)
isCtrl = true;
else
isCtrl = false;
}
//if ctrl is pressed check if other key is in forbidenKeys array
if(isCtrl)
{
for(i=0; i<forbiddenKeys.length; i++)
{
//case-insensitive comparation
if(forbiddenKeys[i].toLowerCase() == String.fromCharCode(key).toLowerCase())
{
alert('Key combination CTRL + '+String.fromCharCode(key) +' has been disabled.');
return false;
}
}
}
return true;
}
</script>
</head>
<body onkeypress="return disableCtrlKeyCombination(event);" onkeydown="return disableCtrlKeyCombination(event);">
Press ctrl and you can check various key is disable with CTRL. like — 'a', 'n', 'c', 'x', 'v', 'j' , 'w' Just add key in above the array and disable key as you want.
</body>
</html>
past where?
ReplyDeleteat html writer were u always write html !!
Deleteif dont understand type on gooogle !!!
vvv
ReplyDeleteThanks , It is very Useful
ReplyDeleteIE & firefox only :( ..
ReplyDeleteIts working all browsers!
DeleteGreat solution...working in all browser
Deletecan u plz tell where to add this in blogger
ReplyDeletethanx man
ReplyDeletehmm http://edelajans.com/
ReplyDeleteYou are amazing, cool, and everything.........words are not enough to say!!!!!
ReplyDeleteYou could definitely see your enthusiasm in the article you write. The world hopes for even more passionate writers like you who aren’t afraid to say how they believe. At all times follow your heart.
ReplyDeletewebsite design
yes very helpful
ReplyDeleteSuperb!! Thanks a ton
ReplyDeleteit's not working in chrome
ReplyDeleteuse full
ReplyDeleteVery usefull thanks!!
ReplyDeletethx its very usefull scripts....!!!!!
ReplyDeletefor ie it is not working
ReplyDeleteThanks, But its not working in chrome. I urgent need to disable it on all browser.
ReplyDeleteits good but how to disable developer tools
ReplyDeleteit works but if you try to press that key ( ctrl + u ) more than one time then it will not working
ReplyDeleteon the line
DeleteforbiddenKeys var = new Array ('a', 'n', 'c', 'x', 'v', 'j', 'w');
You must add the letter 'u' to mention that the variable 'u' will work with the CTRL key, so when you hit ctrl + u will display a Feedback.
should look like this:
forbiddenKeys var = new Array ('a', 'n', 'c', 'x', 'v', 'j', 'w', 'u');
Hope this helps.
Thanks a lot...
ReplyDeleteVery good, tested and approved in recent versions of Chrome, Fire Fox, Opera and Safari.
ReplyDeleteOnly gave error in IE 11, the functions do not work.
Anyone know how to fix?
Thanks and a big hug.
very good and useful information shared. Thanks for sharing this.
ReplyDeletenot working in chrome
ReplyDeleteIts not working in IE9... Can any one please tell me how to solve this??
ReplyDeletecannot work in chrome!
ReplyDeleteMakes no sense. Anyone with a knowledge of F12 tools will bypass everything.
ReplyDeletewhat if we disable right click and F12 both ? :p
DeleteHi... How to disable it on address. Because F12 key is working on addressbar.
DeleteThanks for sharing the important points of view with us. It is really very nice blog which describes how to icici payment gateway plugin
ReplyDeleteThanks...It's Working..:)
ReplyDeleteGreat Article i have learned so many things from your article
ReplyDeletePlease check this and tell me more about it:
http://seowebsitedesigning.com/disable-mouse-right-click-using-jquery/
Thanks for sharing the important points of view with us.
ReplyDeleteThanks a lot...
ReplyDeleteSir i have one question how we create full screen browser while writing online exams please reply me as early as posiable..........
ReplyDelete