How to prevent ctrl + s, f12 default action on a web page?

On a web page, we have premium content that we want visitors not to save or get the source using f12. We can protect it using JavaScript easily.

There are many ways to steal content. So this is not a good thing to do on a web page.

Following is code that will prevent the default behavior of ctrl + s or f12:

jQuery(document).keydown(function (event) {
        if (event.keyCode === 123) { // Prevent F12
            return false;
        } else if (event.ctrlKey && event.shiftKey && event.keyCode === 73) { // Prevent Ctrl+Shift+I
            return false;
        } else if(event.keyCode === 83 && (navigator.platform.match("Mac") ? event.metaKey : event.ctrlKey)){ // Prevent cmd/ctrl + s
            return false;
        }
    });
Share