Last active
November 26, 2022 10:21
-
-
Save pbaruns/2803db7a223808e76ccc05e7217ea3d6 to your computer and use it in GitHub Desktop.
Disable the ctrl u keyboard shortcut
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// disable viewing page source | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | |
<script> | |
document.onkeydown = function(e) { | |
if (e.ctrlKey && | |
(e.keyCode === 67 || | |
e.keyCode === 86 || | |
e.keyCode === 85 || | |
e.keyCode === 117)) { | |
alert('Content is protected\nYou cannot view the page source.'); | |
return false; | |
} else { | |
return true; | |
} | |
}; | |
$(document).keypress("u",function(e) { | |
if(e.ctrlKey) | |
{ | |
return false; | |
} | |
else | |
{ | |
return true; | |
} | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not working