Primefaces Press Enter executes commandButton

This is not a JSF specific behavior, when Enter is pressed the first <input> with type="submit" is used. This has been discussed on SO (see this or this), I'll put here some of the suggestions from those threads.

Javascript solution:

Use <h:form id="thisform" onkeypress="if( event.keyCode == 13){event.keyCode=0;}"> on your form. This, however, will prevent you from having any default command on the form since it catches pressing Enter.

Primefaces solution:

Use a dummy button on the form which does nothing, and set it as form's default command.

<p:defaultCommand target="dummy"/>
<p:commandButton id="dummy" process="@none" global="false" style="display:none;"/>

I had the same issue in my project. To avoid the submit on enter key press I just did like following. At every inputText field added this code,

onkeypress="if (event.keyCode == 13) { return false; }"