3 回答
TA贡献1719条经验 获得超6个赞
keyCode
which
which
var key = 'which' in e ? e.which : e.keyCode;
var key = e.which || e.keyCode || 0;
e.which
0
0
||
TA贡献1829条经验 获得超7个赞
jQuery规范event.which取决于event.which, event.keyCode或event.charCode浏览器支持:
// Add which for key events
if ( event.which == null && (event.charCode != null || event.keyCode != null) ) {
event.which = event.charCode != null ? event.charCode : event.keyCode;
}
额外的好处.whichjQuery也用于鼠标单击:
// Add which for click: 1 === left; 2 === middle; 3 === right
// Note: button is not normalized, so don't use it
if ( !event.which && event.button !== undefined ) {
event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
}
添加回答
举报