TA的每日心情 | 慵懒 2022-3-8 11:41 |
---|
签到天数: 2 天 [LV.1]初来乍到
荣誉开发者
- 积分
- 1381
|
发表于
2023-1-2 12:56:35
|
显示全部楼层
在事件捕获阶段stopImmediatePropagation:https://developer.mozilla.org/zh ... mmediatePropagation
- let holding = 0;
- window.addEventListener('keydown', e => {
- const video = document.querySelector('video');
- if (e.key === 'ArrowRight' && video) {
- e.stopImmediatePropagation();
- holding++;
- if (holding > 1) {
- video.playbackRate = 3;
- }
- }
- }, true);
- window.addEventListener('keyup', e => {
- const video = document.querySelector('video');
- if (e.key === 'ArrowRight' && video) {
- e.stopImmediatePropagation();
- if (holding > 1) {
- video.playbackRate = 1;
- } else {
- video.currentTime += 5;
- }
- holding = 0;
- }
- }, true);
复制代码 |
|