From e0b5972167e551c1c48a3ae0509f5ad12f806161 Mon Sep 17 00:00:00 2001 From: kontrollanten <6680299+kontrollanten@users.noreply.github.com> Date: Fri, 5 Feb 2021 09:48:05 +0100 Subject: [PATCH] client(hotkeys): tighten hotkey definitions --- client/src/assets/player/peertube-player-manager.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/client/src/assets/player/peertube-player-manager.ts b/client/src/assets/player/peertube-player-manager.ts index fcf0d0f41..4ea9fda2e 100644 --- a/client/src/assets/player/peertube-player-manager.ts +++ b/client/src/assets/player/peertube-player-manager.ts @@ -527,6 +527,9 @@ export class PeertubePlayerManager { } private static addHotkeysOptions (plugins: VideoJSPluginOptions) { + const isNaked = (event: KeyboardEvent, key: string) => + (!event.ctrlKey && !event.altKey && !event.metaKey && !event.shiftKey && event.key === key) + Object.assign(plugins, { hotkeys: { skipInitialFocus: true, @@ -542,7 +545,7 @@ export class PeertubePlayerManager { fullscreenKey: function (event: KeyboardEvent) { // fullscreen with the f key or Ctrl+Enter - return event.key === 'f' || (event.ctrlKey && event.key === 'Enter') + return isNaked(event, 'f') || (!event.altKey && event.ctrlKey && event.key === 'Enter') }, seekStep: function (event: KeyboardEvent) { @@ -561,7 +564,7 @@ export class PeertubePlayerManager { customKeys: { increasePlaybackRateKey: { key: function (event: KeyboardEvent) { - return event.key === '>' + return isNaked(event, '>') }, handler: function (player: videojs.Player) { const newValue = Math.min(player.playbackRate() + 0.1, 5) @@ -570,7 +573,7 @@ export class PeertubePlayerManager { }, decreasePlaybackRateKey: { key: function (event: KeyboardEvent) { - return event.key === '<' + return isNaked(event, '<') }, handler: function (player: videojs.Player) { const newValue = Math.max(player.playbackRate() - 0.1, 0.10) @@ -579,7 +582,7 @@ export class PeertubePlayerManager { }, frameByFrame: { key: function (event: KeyboardEvent) { - return event.key === '.' + return isNaked(event, '.') }, handler: function (player: videojs.Player) { player.pause()