3

I'm trying to disable the print screen key on my website. This is what I have so far:

<SCRIPT type="text/javascript">
focusInput = function()
{
    document.focus();
};

processKeyEvent = function(eventType, event)
{
    if (window.event)
    {
        event = window.event;    
    }
    if(event.keyCode == 44) 
    {
        alert("Photos are copyright 2011");
        return(false);
    }
}
processKeyUp = function(event)
{
    processKeyEvent("onkeyup", event);
};

processKeyDown = function(event)
{
    processKeyEvent("onkeydown", event);
};

document.onkeyup = processKeyUp;
document.onkeydown = processKeyDown;

</SCRIPT>

But this isn't working. How can I disable the print screen key to prevent users from making a snapshot of my site?

Mike Cluck
  • 31,869
  • 13
  • 80
  • 91
AtmiyaDas2014
  • 300
  • 1
  • 3
  • 25
  • 8
    Even if you want users to not take screenshots of their screen, you still can't stop them from doing stuff like checking the page source and downloading the image directly, or using screen capturing software like Fraps, or even just taking a (low quality) picture of their screen with their phone. If a user really wants to use your photos, they will find a way around it. If you want users to obey copyright, invest in some lawyers and aggressively sue everyone who you suspect is pirating your images, and mark your website that you will do as such. Then watch as your usercount plummets... – Nzall Jul 14 '14 at 09:19
  • 3
    Personally I'd bypass this by clicking on the Taskbar to put the focus there, *then* push PrntScr ;) – Niet the Dark Absol Jul 14 '14 at 09:41
  • please give me your code niet the dark absol – AtmiyaDas2014 Jul 14 '14 at 10:52
  • 1
    -1 because dont do that – wim Jul 14 '14 at 11:11

1 Answers1

28

You can't. It's beyond your control, because print screen (unlike the in-browser print icon/Ctrl-P) is not a browser feature but a system feature.

Besides, any such attempt is futile and ultimately counter-productive. Because you will piss off the Joe Random User who wants to print the page because they want to read it on the bus or whatever and won't stop somebody who wants to abuse the images as they can always take advantage of the fact that the device is ultimately under their physical control and no software in the world can do anything against modification of the device (e.g. using a monitor with screen capture).

Jan Hudec
  • 73,652
  • 13
  • 125
  • 172
  • 2
    "using a monitor with screen capture"--Someone could just use a VM with its own capture functionality. – nanofarad Jul 14 '14 at 10:50
  • 1
    @hexafraction: VM could possibly be detected (by some software, not normal browser), but no software can do anything about capturing display unit. So I mention that as more general argument that no software copy protection at all will ever work against determined opponent. – Jan Hudec Jul 14 '14 at 11:57