Click to See Complete Forum and Search --> : disable keyboard key


catchup
06-14-2003, 08:45 AM
:) Hi,
the following disables any key on the keyboard that has a numeric code associated with it, ex. f5 being 116, what if i wanted to diasble the print screen key? any ideas? I know one could blur the page and still then print screen, I'm not concerned with that as i'm on a mission to diable printscreen key via JS webpage... and suggestions?


//Disable right mouse click Script
var message="Function Disabled!";

function clickIE4(){if (event.button==2){alert(message);return false;}}

function clickNS4(e){if (document.layers||document.getElementById&&!document.all){if (e.which==2||e.which==3){alert(message);return false;}}}

if (document.layers){document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS4;}
else if (document.all&&!document.getElementById){document.onmousedown=clickIE4;}
document.oncontextmenu=new Function("alert(message);return false")

//Disable f5 key
if (document.all){
document.onkeydown = function (){
var key_f5 = 116; // 116 = F5

if (key_f5==event.keyCode){
alert("Refreshing the browser will add the record again. Please choose cancel when asked to refresh.");
return false;
}
}
}

Khalid Ali
06-14-2003, 10:49 AM
the key code for "PrintScreen" key is
44

catchup
06-16-2003, 01:17 AM
that weird... 44 you say, i'm on win98 machine and the print screen button works but no numeric value associated to it, at least non i can find. A buddy said his was 45. this is confusing?

Can some people post what their print screen numeric value is.

thanks