<!DOCTYPE html>
<html>
<head>
<title>Disable Right click</title>
<script type="text/javascript">
document.onkeydown = function(e) {
// keycode for F5 function
console.log('You just pressed a key with code'+e.keyCode);
document.getElementById('danger').innerHTML = 'You just pressed a key with code '+e.keyCode;
if (e.keyCode == 123) {
document.getElementById('danger').innerHTML = 'You just pressed a key with code '+e.keyCode+' and this key has been disabled';
return false;
}
};
</script>
<style>
.no_click{
background-color: black;
width: 100%;
min-height: 300px;
color: red;
}
.danger{
display: block;
width: 60%;
color: white;
}
code{
width: 200px;
}
</style>
</head>
<body>
<div class="no_click" style="border:1px solid Red;">
<p>KEY DISABLE!!!</p>
<span id="danger">
</span>
</div>
<p>To disable a key, you can get the key code and then replace 'KEY_CODE' with it in the below code</p>
<code>
document.onkeydown = function(e) {
// keycode for F5 function
console.log('You just pressed a key with code'+e.keyCode);
document.getElementById('danger').innerHTML = 'You just pressed a key with code '+e.keyCode;
if (e.keyCode == KEY_CODE) {
document.getElementById('danger').innerHTML = 'You just pressed a key with code '+e.keyCode+' and this key has been disabled';
return false;
}
};
</code>
</body>
</html>
This is a snippet for disabling keys using javascript, but the default key that's disabled in this snippet is the F12 key which is a shortcut key for developers option. you can use this to totally disable developer's option if you use it with this tutorial https://codepad.co/snippet/6slAo5MR
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.