Wow. Who would have known it? That was in D6 as well.<br><br>I opened <a href="http://drupal.org/node/857702">http://drupal.org/node/857702</a> to take care of this.<br><br>If you want to take that one, feel free, or if you just want to post a paragraph about usage there I&#39;ll get it into the FAPI reference.<br>
<br>-Randy<br><br><div class="gmail_quote">On Sun, Jul 18, 2010 at 12:21 PM, Darren Oh <span dir="ltr">&lt;<a href="mailto:darrenoh@sidepotsinternational.com">darrenoh@sidepotsinternational.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Good news: if you add &#39;keypress&#39; =&gt; &#39;true&#39; to the form element&#39;s #ajax array, Drupal takes care of this automatically.<br>
<div><div></div><div class="h5"><br>
On Jul 16, 2010, at 3:04 PM, Pierre Rineau wrote:<br>
<br>
&gt; Le vendredi 16 juillet 2010 à 08:21 -0400, Darren Oh a écrit :<br>
&gt;&gt; Does Drupal 7 provide a way to AJAX-submit a form when the Enter key is pressed in a text field? I tried using &quot;submit&quot; as the event in the #ajax array, but that didn&#39;t prevent a page reload.<br>
&gt;<br>
&gt; There is no easy way to capture enter key event, you will need<br>
&gt; javascript code.<br>
&gt;<br>
&gt; You can see this module <a href="http://drupal.org/project/default_submit" target="_blank">http://drupal.org/project/default_submit</a> (I did<br>
&gt; it, by I do not advice you to use it!) which implements one way to do it<br>
&gt; (not the better).<br>
&gt;<br>
&gt; Most browsers will use the first submit or button in the current focused<br>
&gt; form when the user click enters, but a lot of others will just do<br>
&gt; nothing.<br>
&gt;<br>
&gt; JavaScript is the key!<br>
&gt;<br>
&gt; Pierre.<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Randy Fay<br>Drupal Module and Site Development<br><a href="mailto:randy@randyfay.com">randy@randyfay.com</a><br>+1  970.462.7450<br><br>