<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
</body>
<script>
var multiKeyPress = {
keyPressTimes: 0,
// 2秒内5连击(默认)________________________
trigger(
multiKeyPressCallback,
singleClickCallback,
maxTimes = 5,
time = 2000
) {
this.keyPressTimes || (this.keyPressTimes = 0);
++this.keyPressTimes >= maxTimes &&
(multiKeyPressCallback && multiKeyPressCallback(),
singleClickCallback || (this.keyPressTimes = 0));
this.keyPressTimes === 1 &&
setTimeout(() => {
this.keyPressTimes < maxTimes &&
singleClickCallback &&
singleClickCallback(); //执行单击键盘or少于maxTimes次数的点击
this.keyPressTimes = 0;
}, time);
}
};

/*设置快捷键*/
onkeyup = e => {
var k = e.keyCode || e.which || e.charCode, ck = e.ctrlKey || e.metaKey, ak = e.altKey, sk = e.shiftKey;/*独立键*/
if (k === 19) {/*按下Pause/Break键时候执行*/
multiKeyPress.trigger(
() => {
// 双击键盘
alert(`【更新时间】${versionTime}\n(注意校对是否已发布最新代码)`);
},
() => {
// 单击键盘
console.count();
console.log("单击Pause/Break键");
}, 2, 300
);
}
};
var versionTime='2021年01月01日 00:00:00';
</script>
</html>