I have in the header of a website an a4j:commandButton which responds to some events triggered from the keyboard of the computer, when I press enter on the keyboard the action of said commandButton is launched, and when I press the delete button on the keyboard it travels back to the previous screen wherever you were. If I remove the button, none of this happens.
How could I control it?
This has nothing to do with JSF, but with plain HTML.
<a4j:commandButton ...>
is rendered in a<button type="submit" ...>
. By default, submit buttons have shortcuts ; in most browsers it is the same:You can solve this problem using JavaScript:
To prevent the submit of the form when an Enter is pressed, you must listen for the keyup event on the form and detect if Enter has been pressed.
PS: RichFaces has been declared discontinued by RedHat. It is recommended to use plain JSF or another extension library.