|
> From: Peter Vidal > > ... and be able to not to go back to the browser defaults if I press F11. I know that for Internet Explorer, you can define an onkeydown event, then disable the keystroke if you don't like it. <script> function checkKey() { if (window.event.keyCode == 122) { window.event.keyCode = 0; return false; } return true; } </script> <body onkeydown='return checkKey();'> This code will disable F11 (key number 122). It also disables F23, because it is Shift-F11. It also disables Ctrl-F11, Alt-F11 and so on (you can test other flags in the event object to determine the state of Alt/Ctrl/Shift). I'm pretty sure both setting the keyCode to zero and returning false is required to disable the key. IIRC, setting the keyCode to zero prevents the key from doing what it is supposed to do, while returning false prevents the event from bubbling to other listeners. This tends to not work with Netscape/Mozilla, because so much of the DOM is read-only, including the event fields. Joe
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.