From 48b81536a8ae1594820b4e51615954ad7b868d9c Mon Sep 17 00:00:00 2001 From: Harvey Date: Fri, 22 Nov 2019 17:48:13 +0800 Subject: [PATCH] Update hotkey.js --- packages/artplayer/src/hotkey.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/packages/artplayer/src/hotkey.js b/packages/artplayer/src/hotkey.js index e91d08c3c..155ad3b75 100644 --- a/packages/artplayer/src/hotkey.js +++ b/packages/artplayer/src/hotkey.js @@ -1,35 +1,41 @@ export default class Hotkey { constructor(art) { this.keys = {}; - if (art.option.hotkey) { + + const { + option, + player, + events: { proxy }, + } = art; + + if (option.hotkey) { art.on('ready', () => { this.add(27, () => { - if (art.player.fullscreenWeb) { - art.player.fullscreenWeb = false; + if (player.fullscreenWeb) { + player.fullscreenWeb = false; } }); this.add(32, () => { - art.player.toggle = true; + player.toggle = true; }); this.add(37, () => { - art.player.seek = art.player.currentTime - 5; + player.seek = player.currentTime - 5; }); this.add(38, () => { - art.player.volume += 0.1; + player.volume += 0.1; }); this.add(39, () => { - art.player.seek = art.player.currentTime + 5; + player.seek = player.currentTime + 5; }); this.add(40, () => { - art.player.volume -= 0.1; + player.volume -= 0.1; }); - const { proxy } = art.events; proxy(window, 'keydown', event => { if (art.isFocus) { const tag = document.activeElement.tagName.toUpperCase();