This has nothing to do with JSF, if not with simple HTML. <a4j:commandButton ...>
is rendered in a <button type="submit" ...>
. By default, submit buttons have shortcuts ; in most browsers it's the same:
- Enter: triggers the submit event
- Delete: go back to the previous page
This problem can be solved using JavaScript:
$(document).on("keydown", function (e) {
if (e.which === 8 && !$(e.target).is("input, textarea")) {
e.preventDefault();
}
});
To avoid submitting the form when an Enter is pressed, you should listen for a keyup event in the form and detect if you have pressed Enter.
$('#tuform').on('keyup', function(e) {
var keyCode = e.keyCode || e.which;
if (keyCode === 13) { // Se detecta Enter
e.preventDefault();
return false;
}
});
PD: RichFaces has been declared discontinued by RedHat. It is recommended to use flat JSF or another extension library.