Catching [enter] in dropdownlist control

  • Thread starter Thread starter Anders K. Jacobsen [DK]
  • Start date Start date
A

Anders K. Jacobsen [DK]

Hi

I have a problem delegating a [enter] keydown event to a button control when
inside a a DropDownList control.

I have this

Enter name: [Textbox] Select Birth year [DropDownControl] [Button].

When the cursor is in the textbox i can catch the button event by assign
button as default button. But when inside the DropDownList the button event
is never executed. I want this behavior for userablity reason.

Any suggestions?

Thanks in regards
Anders Jacobsen
 
I don't think you can. I say that because: if you go to google's advanced
search (http://www.google.com/advanced_search?hl=en) and type some text in a
textbox and hit enter, it submits. If you put the focus on a dropdown box,
it doesn't. Hey if google can't do it...

It might be possible to get a keydown event on the body, see what the event
target was and do something from that though...

Karl
 
A thought; set a flag in your JS on the onFocus event for the dropdown.
Then if the form submits you could check that the onClick event has been
fired for the Submit button.

You can trap buttons on the <body> tag. For instance this traps the esc
key.

<body onkeypress="if (window.event.keyCode=='27') DoSomeFunction();">


Glenn
 
A thought; set a flag in your JS on the onFocus event for the dropdown.
Then if the form submits you could check that the onClick event has been
fired for the Submit button.

You can trap buttons on the <body> tag. For instance this traps the esc
key.

<body onkeypress="if (window.event.keyCode=='27') DoSomeFunction();">

I will look into it. I wil post back with the posible solution.

Anders
 

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

Back
Top