Cancelling Function Keys in Netscape with Javascript

M

mgw

Hi,

I'm trying to cancel the Shift+F3 key combination in Netscape 7.2 from
performing the F3 key's default action of opening the Find dialog. I'm
unable thus far to prevent the Find dialog from appearing after
following steps listed in numerous posts in this group.

I detect the onkeydown event of the body as follows:

<body onkeydown="return bodyOnKeyPress(event);">

My bodyOnKeyPress event is as follows:

function bodyOnKeyPress(evt)
{
if(evt.keyCode == 114 && evt.shiftKey)
{
if(navigator.appName == "Netscape")
{
evt.preventDefault();
}
else
{
evt.keyCode = 0;
evt.returnValue = false;
}

evt.cancelBubble = true;
return false;
}
}

Does anyone see perhaps something that I'm doing wrong? Any help would
be greatly appreciated.

Thanks,
Mike
 
M

Martin Honnen

mgw wrote:

I detect the onkeydown event of the body as follows:

<body onkeydown="return bodyOnKeyPress(event);">

Well you can only cancel keypress events in Netscape/Mozilla so try
<body onkeypress="return bodyOnKeyPress(event);">
 
M

Michael Winter

[snip]

Martin answered your question, but...
if(navigator.appName == "Netscape")
{
evt.preventDefault();
}

....nonsense.

if(evt.preventDefault) {
evt.preventDefault();
}

[snip]

Mike
 
M

mgw

I have changed the code to match your suggestion...

[snip]
if(evt.preventDefault) {
evt.preventDefault();
}
[snip]

....unfortunately the Find dialog is still being displayed. Is it
really not possible to prevent the display of this dialog by
cancelling out the pressing of the F3 key?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,264
Messages
2,571,065
Members
48,770
Latest member
ElysaD

Latest Threads

Top