Entry
Can I disable any of the function keys using JavaScript?
Yes this is fine as long as I have a document without frames. How can i implement it for all frames
Apr 4th, 2008 19:52
ha mo, Darton Williams, Bj Price, Colin Fraser, Vicky Hora, chitra prakash,
(As mentioned elsewhere on this site)
I found a way to do it, but it only works in IE and I've only tested it
in IE5+. Netscape doesn't seem to return anything for function keys. If
you trap the keyCode you want to disable and assign a new value to it,
you can do whatever you want with the function keys. The keycodes for
them are 112 - 123. The only real use I've found for this is in a
proprietary app I'm developing for IE, but I guess you could also annoy
the heck out of some people with it.
document.onkeydown = function(){
if(window.event && window.event.keyCode == 116)
{ // Capture and remap F5
window.event.keyCode = 505;
}
if(window.event && window.event.keyCode == 505)
{ // New action for F5
alert('F5 key was pressed');
return false;
// Must return false or the browser will refresh anyway
}
}
This will not intercept F1 or F4 in IE 6. Anybody have any guesses how
to?
F1 doesn't need to be remapped in the same way as the others, because
document.onhelp will override the default function. Still checking on
the F4 thing.
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com