473,738 Members | 5,934 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 defaultEventHan dler = obj.getEvent("o nkeydown");

var myEventHandler = function(event) {
if(event.keyCod e==13){
alert(obj.getPr operty("selecti on/index"));
}
else{
defaultEventHan dler.call(this, event);
}
}
obj.setEvent("o nkeydown", myEventHandler) ;

But it won't even enter the function. Thanks!
Aug 11 '05 #1
3 6927
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.javas cript 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
2106
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 i want to focus next. the following are the test code i have, whenever i hit "enter", it will act clicking the submit button. what can i do to avoid this problem? <!-- ############# code begins here ############ --> <html> <head>
2
15636
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 & textBox2_Enter ), add the code TextBox1.SelectAll(); and TextBox2.SelectAll(); Run the App. When you run the app with a breakpoint at textBox1_Enter(), and
3
3643
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 page, 2) Breakpoint in the Page_Load, 3) debug the web page and click the submit button, 4) "step into" under debug several times, 5) The debugger does not stop at any of the statements in the click event handler. A breakpoint is needed in each...
0
900
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 that when I will hit enter in my input field, I expect to form to be posted back to the server and the event handler for the TextChanged event to be called. If i tabulate from my text field, everythign is working fine. Nevertheless
1
11580
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 http://weblogs.asp.net/asmith/archive/2003/09/15/27684.aspx but it was far more complex then I needed. (I got lost trying to figure it all out). Therefore, here goes my simple "web dialog box with parent event handler fireing" solution. ...
3
7275
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 event handler, right? Ok. If the focus is set to any other control than a button, then the above event handler fires, but if the focus is on a button, then I've no way to know that the Enter key has been pressed or not, because in that case pressing...
7
1447
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 complicated application which seems to me to be misbehaving. The following is an attempt to reproduce the error. There are reasons in the real application why I'm trying to do things the way they are here, so please no comments on techniques here,...
17
9676
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 event. But if I press the button without entering text first, the button click event does work. What's up? <html> <body> <h3>Events on Buttons and Text Boxes</h3>
4
5693
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 Event. The problem I have is that the application finishes and exits before the AdvanceSearch, so the Event Handler in never called. If I delay the end of the application, for example, by having message box right after the call to AdvancedSearch,...
1
3364
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 save time and not have to put a event handler in every form class. The base class has an event handler for Edit.Enter and Edit.Leave so that it can turn the Edit menu items on and off.
0
8969
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8788
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9476
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9335
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9263
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9208
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8210
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4570
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.