473,386 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Event handler for Enter key

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!
Aug 11 '05 #1
3 6915
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?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Aug 11 '05 #2
Simon Wigzell wrote:
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
Aug 12 '05 #3

"Robert" <ro****@noreply.x> wrote in message
news:42***********************@news.xs4all.nl...
Simon Wigzell wrote:
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


Yes, that is what I wanted, thanks. I'll have to work around it.
Aug 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Alan Zhong | last post by:
i am trying to similate an "ENTER" as a key to switch focus in a sequence of text inputs. i don't want to use "event.keyCode" since i want to do additional testing before i decide which text input...
2
by: bullshark | last post by:
VSN03:C# Create a C# Windows Form project. Add two TextBox controls. From the Properties of each, add an Enter Event handler. In the generated Enter Event Handlers (textBox1_Enter &...
3
by: R Millman | last post by:
under ASP.NET, single stepping in debug mode appears not to stop within event procedures. i.e. 1) Create web page with submit button and event procedure for the click event in the code behind...
0
by: Francois Malgreve | last post by:
Hi all, I have a more or less complex form with a few buttons and a few input fields. One of my my input field ( a TextBox) I have an event handler for the TextChanged event. What I want is...
1
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at...
3
by: Nikolay Evseev | last post by:
Hi, I am trying to trace down the Enter key in my Form.KeyPress event handler. The KeyPreview property is set to false, so I'd assume that all key presses should go through my form's KeyPress...
7
by: ChrisM | last post by:
I posted this last week, so apologies for re-posting but I'm still looking for a sensible answer, and I'm hoping somone new might be able to cast some light... Basically, I have a fairly...
17
by: Eric | last post by:
I'm new to JavaScript and I wrote this code to play with. Oddly, if I enter text in a box and then press the button, I only get the onChange event for the text box and not the button's onclick...
4
by: federico | last post by:
Hello, I am trying to setup a Visual Basic "Console" application for searching Outlook folders. To this end I am trying to implement a Handler for the Outlook.Application.AdvancedSearchComplete...
1
by: AliR \(VC++ MVP\) | last post by:
Hi Everyone, I have a few form classes that inherit from the same base class. The main reason that this is done is that some event handlers are common between these classes and I was trying to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.