aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorkontrollanten <6680299+kontrollanten@users.noreply.github.com>2021-02-05 09:48:05 +0100
committerChocobozzz <chocobozzz@cpy.re>2021-02-16 10:37:01 +0100
commite0b5972167e551c1c48a3ae0509f5ad12f806161 (patch)
tree1c41ea5737b50f409710ce17a63fb4bb8bb8d485
parent1664bc60eb7aa3fa3792b6acff50f9bbabd3d877 (diff)
downloadPeerTube-e0b5972167e551c1c48a3ae0509f5ad12f806161.tar.gz
PeerTube-e0b5972167e551c1c48a3ae0509f5ad12f806161.tar.zst
PeerTube-e0b5972167e551c1c48a3ae0509f5ad12f806161.zip
client(hotkeys): tighten hotkey definitions
-rw-r--r--client/src/assets/player/peertube-player-manager.ts11
1 files 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 {
527 } 527 }
528 528
529 private static addHotkeysOptions (plugins: VideoJSPluginOptions) { 529 private static addHotkeysOptions (plugins: VideoJSPluginOptions) {
530 const isNaked = (event: KeyboardEvent, key: string) =>
531 (!event.ctrlKey && !event.altKey && !event.metaKey && !event.shiftKey && event.key === key)
532
530 Object.assign(plugins, { 533 Object.assign(plugins, {
531 hotkeys: { 534 hotkeys: {
532 skipInitialFocus: true, 535 skipInitialFocus: true,
@@ -542,7 +545,7 @@ export class PeertubePlayerManager {
542 545
543 fullscreenKey: function (event: KeyboardEvent) { 546 fullscreenKey: function (event: KeyboardEvent) {
544 // fullscreen with the f key or Ctrl+Enter 547 // fullscreen with the f key or Ctrl+Enter
545 return event.key === 'f' || (event.ctrlKey && event.key === 'Enter') 548 return isNaked(event, 'f') || (!event.altKey && event.ctrlKey && event.key === 'Enter')
546 }, 549 },
547 550
548 seekStep: function (event: KeyboardEvent) { 551 seekStep: function (event: KeyboardEvent) {
@@ -561,7 +564,7 @@ export class PeertubePlayerManager {
561 customKeys: { 564 customKeys: {
562 increasePlaybackRateKey: { 565 increasePlaybackRateKey: {
563 key: function (event: KeyboardEvent) { 566 key: function (event: KeyboardEvent) {
564 return event.key === '>' 567 return isNaked(event, '>')
565 }, 568 },
566 handler: function (player: videojs.Player) { 569 handler: function (player: videojs.Player) {
567 const newValue = Math.min(player.playbackRate() + 0.1, 5) 570 const newValue = Math.min(player.playbackRate() + 0.1, 5)
@@ -570,7 +573,7 @@ export class PeertubePlayerManager {
570 }, 573 },
571 decreasePlaybackRateKey: { 574 decreasePlaybackRateKey: {
572 key: function (event: KeyboardEvent) { 575 key: function (event: KeyboardEvent) {
573 return event.key === '<' 576 return isNaked(event, '<')
574 }, 577 },
575 handler: function (player: videojs.Player) { 578 handler: function (player: videojs.Player) {
576 const newValue = Math.max(player.playbackRate() - 0.1, 0.10) 579 const newValue = Math.max(player.playbackRate() - 0.1, 0.10)
@@ -579,7 +582,7 @@ export class PeertubePlayerManager {
579 }, 582 },
580 frameByFrame: { 583 frameByFrame: {
581 key: function (event: KeyboardEvent) { 584 key: function (event: KeyboardEvent) {
582 return event.key === '.' 585 return isNaked(event, '.')
583 }, 586 },
584 handler: function (player: videojs.Player) { 587 handler: function (player: videojs.Player) {
585 player.pause() 588 player.pause()