Event handler for Enter key

S

Simon Wigzell

How can I interrupt the enter key so it won't trigger unwanted events on my
web page? I have tried this:

var defaultEventHandler = obj.getEvent("onkeydown");

var myEventHandler = function(event){
if(event.keyCode==13){
alert(obj.getProperty("selection/index"));
}
else{
defaultEventHandler.call(this, event);
}
}
obj.setEvent("onkeydown", myEventHandler);

But it won't even enter the function. Thanks!
 
R

Randy Webb

Simon Wigzell said the following on 8/11/2005 12:19 PM:
How can I interrupt the enter key so it won't trigger unwanted events on my
web page? I have tried this:

Redesign your webpage so that the enter key does not trigger unwanted
events.

What are you really trying to do?
 
R

Robert

Simon said:
How can I interrupt the enter key so it won't trigger unwanted events on my
web page?

If I understand correctly you want to set a keypress event handler on
the document and see if the enter key is pressed and in that case
prevent any other events that it may trigger.

This is possible in the DOM2 Event Model, because you can catch events
in the 'capture phase'. However Internet Explorer only supports the
'bubbling phase'.

So to my knowledge what you want is unfortunately not possible.

Robert
 
S

Simon Wigzell

Robert said:
If I understand correctly you want to set a keypress event handler on the
document and see if the enter key is pressed and in that case prevent any
other events that it may trigger.

This is possible in the DOM2 Event Model, because you can catch events in
the 'capture phase'. However Internet Explorer only supports the 'bubbling
phase'.

So to my knowledge what you want is unfortunately not possible.

Robert

Yes, that is what I wanted, thanks. I'll have to work around it.
 

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

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top