Click here to Skip to main content
14,928,868 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Hi,
I want to disable print screen button in website.
I am able to disable right click and other options, like cut, copy, paste, save, open, print, etc using the following code:


$(document).ready(function () {

$("body").on("contextmenu",function(e){
return false;
});

$("body").bind("keyup keydown", function(e) {
e.preventDefault();
return false;
});

});


But, I am not getting success in disabling print screen button.

What I have tried:


$(document).ready(function () {

$("body").bind("keydown", function(e) {
if (e.keyCode == 44) {
return false;
}
});

});
Posted
Updated 22-Mar-17 8:51am

You can't disable any buttons or any browser features. You might think you have disabled right-click but you haven't, I can still copy etc from your site, and you can't disable print screen or anything else.
   
In addition to the answer by F-ES Sitecore:

The PrintScreen button is handled by the OS of the client PC. By default it is even not passed to running applications like a web browser. The only solution is to let an application hook the keyboard input using an OS specific method. But such is not supported by JavaScript.
   
Comments
FalconMadhab 28-Jun-18 2:22am
   
Do any other language can help me achieve it.
Web pages can not control all or part of the client PC for security reasons.
The only possibility is to install a windows app (with user agreement) that will extend the possibilities of web pages (just like to read pdf files in browser.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900