在JSF 1.2中,我正在使用h:commandButton type="button",但是当我在它上面按Tab键并按Enter键时,按钮不会触发。我尝试使用
onkeypress="keyEnter(event)"
。 function keyEnter(eve){
if (eve.keyCode == 13) {
document.getElementById(eve.target.id).click();
}
return false;
}
当按下回车键时,它会触发按钮。现在我的问题是,我有很多类型为button的h:commandButton元素,我该如何实现将keyEnter(eve)应用于所有按钮元素?
提前感谢您的帮助。