监听整个文档的 Key up 事件,判断回车
1. jquery
$(document).keyup(function(e){
var key = e.which;
if(key==13){
/*Do something. 调用一些方法*/
}
});
2. javascript
document.onkeyup = function(e) {
// 兼容FF和IE和Opera
var event = e || window.event;
var key = event.which || event.keyCode || event.charCode;
if (key == 13) {
/*Do something. 调用一些方法*/
}
};