Wow. Who would have known it? That was in D6 as well.

I opened http://drupal.org/node/857702 to take care of this.

If you want to take that one, feel free, or if you just want to post a
paragraph about usage there I'll get it into the FAPI reference.

-Randy

On Sun, Jul 18, 2010 at 12:21 PM, Darren Oh <
[email protected]> wrote:

> Good news: if you add 'keypress' => 'true' to the form element's #ajax
> array, Drupal takes care of this automatically.
>
> On Jul 16, 2010, at 3:04 PM, Pierre Rineau wrote:
>
> > Le vendredi 16 juillet 2010 à 08:21 -0400, Darren Oh a écrit :
> >> Does Drupal 7 provide a way to AJAX-submit a form when the Enter key is
> pressed in a text field? I tried using "submit" as the event in the #ajax
> array, but that didn't prevent a page reload.
> >
> > There is no easy way to capture enter key event, you will need
> > javascript code.
> >
> > You can see this module http://drupal.org/project/default_submit (I did
> > it, by I do not advice you to use it!) which implements one way to do it
> > (not the better).
> >
> > Most browsers will use the first submit or button in the current focused
> > form when the user click enters, but a lot of others will just do
> > nothing.
> >
> > JavaScript is the key!
> >
> > Pierre.
>



-- 
Randy Fay
Drupal Module and Site Development
[email protected]
+1  970.462.7450

Reply via email to