Entry
How can I disable all the function keys and redirect them to my links?
May 16th, 2006 23:35
kris kris, Eric Christopherson,
capture the onkeypress event and add some functionality to get the
keycode of events fired by FunctionKeys(F1-F12)..
evt.charCode will return 0 in Firefox, so you need to use
evt.keyCode, iam adding my sample code which disabling the F5 & CTRL+R
functionality in Firefox & Netscape.
the event codes start from (F1[112] to F12[123]}....
the numbers in Square brackets indicates the keycode of the function key.
if(browser == "Netscape")
{
document.onkeypress = function (evt)
{
var r = '';
if (document.getElementById)
{
r += evt.ctrlKey ? 'Ctrl-' : '';
r += evt.charCode;
if(evt.keyCode =="116" || r == "Ctrl-114") // event fired by NS when
F5(keycode:116) button is pressed.
// add your functionality here.
{ evt.preventDefault();
evt.stopPropagation();
return false;
}
}
}
}
here iam capturing the events.. and u do ur work inside the block..
Hope this solves your problem..
thanks,
krishna