View Full Version : Disable Hotkeys for Netscape 6 & 7?

04-07-2003, 08:59 PM
I'm trying to figure out how to disable certain hotkeys (ctrl + n, ctrl + o, etc...) and i'm having some trouble with netscape 6 and 7 browsers. Heres what i've got right now...

// called onLoad
function WinOpen () {

try {
} catch (err) {
document.write("Sorry, you can not enjoy this site because of " + err + ".");
return false;


// code on newly opened window (disabled hotkey window)
function docKeyDown (event) {

if(event.ctrlKey && event.keyCode == 78) {
alert('ctrl + n hit');
event.cancelBubble = true;
return false;



In this script, i'm detected for <ctrl> + <n> and it successfully detects the hotkey combo (by displaying alertbox), but it also opens up a new browser window, which i don't want.

Any ideas, or prior experience?

04-07-2003, 09:13 PM
<preaching>Trying to stop the user from opening a new window is really bad behavior from a website and should be avoided. A website is intended to be a document, not an application - and a document shouldn't be able to disable or even change any portion of the user interface. Some things in the user interface already can't be changed or stopped, even if they can be detected - and while detection might be good, changing really isn't.

In short, don't even try to do that. You can't prevent it from a user who knows the system anyway, and most mozilla users aren't just Joe Average when it comes to computer skills - it's a browser popular among web designers, scripters, programers and other computer circles.


Well, the fact is, I believe you can't override most of the user interface features, such as opening a new window, opening the DOM Inspector etc. That is, from my point of view, the way things are supposed to be. If you're making an application, try XUL.

04-07-2003, 09:38 PM
Thank you, but i know the ramifications of what i am tring to do and it has nothing to do with a public website.

04-07-2003, 10:05 PM
Well, I'm sorry to say, but you'll remain limited by the rules that apply to websites even if you have an application, if you're running it as html. A xul/xbl interface to load the html document should be able to access some more features, probably also change key binding. I don't know if that's a viable solution to you, though.

04-07-2003, 11:35 PM
Well i figured it out anyway...instead of this...


this worked for me...


keypress instead of keydown.

Dispite what you think *should* happen with the behavior of a browser liorean, certain characteristics like this are allowed, with user permission or signed scripts...maybe you should read up on that.