绑定键盘事件
<div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">取消</button> <button type="button" class="btn btn-primary" data-dismiss="modal" id="hold">保存</button> </div>
1 //添加键盘事件 2 document.onkeyup = function (event){ 3 var e = event || window.event; 4 var keyword = e.keyCode || e.which; 5 switch(keyword){ 6 case 13: 7 document.getElementById("hold").click(); 8 9 } 10 }