I have one requirement for one page. On that page, I want to block the user from performing the below actions,
- Right Click
- F12
- Ctrl + Shift + I
- Ctrl + Shift + J
- Ctrl + Shift + C
- Ctrl + U
For this, I googled and finally got the below link,
http://andrewstutorials.blogspot.in/2014/03/disable-ways-to-open-inspect-element-in.html
I tested it with Chrome & Firefox. It’s working for my requirement.
Right Click
<body oncontextmenu="return false">
Keys
document.onkeydown = (e) => {
if (e.key == 123) {
e.preventDefault();
}
if (e.ctrlKey && e.shiftKey && e.key == 'I') {
e.preventDefault();
}
if (e.ctrlKey && e.shiftKey && e.key == 'C') {
e.preventDefault();
}
if (e.ctrlKey && e.shiftKey && e.key == 'J') {
e.preventDefault();
}
if (e.ctrlKey && e.key == 'U') {
e.preventDefault();
}
};