@@ -374,6 +374,8 @@ class Player extends Component {
374374
375375 this . boundUpdatePlayerHeightOnAudioOnlyMode_ = ( e ) => this . updatePlayerHeightOnAudioOnlyMode_ ( e ) ;
376376
377+ this . boundGlobalKeydown_ = ( e ) => this . handleGlobalKeydown_ ( e ) ;
378+
377379 // default isFullscreen_ to false
378380 this . isFullscreen_ = false ;
379381
@@ -615,6 +617,10 @@ class Player extends Component {
615617 this . on ( 'keydown' , ( e ) => this . handleKeyDown ( e ) ) ;
616618 this . on ( 'languagechange' , ( e ) => this . handleLanguagechange ( e ) ) ;
617619
620+ if ( this . isGlobalHotKeysEnabled ( ) ) {
621+ Events . on ( document . body , 'keydown' , this . boundGlobalKeydown_ ) ;
622+ }
623+
618624 this . breakpoints ( this . options_ . breakpoints ) ;
619625 this . responsive ( this . options_ . responsive ) ;
620626
@@ -650,6 +656,7 @@ class Player extends Component {
650656 // Make sure all player-specific document listeners are unbound. This is
651657 Events . off ( document , this . fsApi_ . fullscreenchange , this . boundDocumentFullscreenChange_ ) ;
652658 Events . off ( document , 'keydown' , this . boundFullWindowOnEscKey_ ) ;
659+ Events . off ( document . body , 'keydown' , this . boundGlobalKeydown_ ) ;
653660
654661 if ( this . styleEl_ && this . styleEl_ . parentNode ) {
655662 this . styleEl_ . parentNode . removeChild ( this . styleEl_ ) ;
@@ -2251,6 +2258,12 @@ class Player extends Component {
22512258 this . trigger ( 'textdata' , data ) ;
22522259 }
22532260
2261+ handleGlobalKeydown_ ( event ) {
2262+ if ( event . target === document . body ) {
2263+ this . handleKeyDown ( event ) ;
2264+ }
2265+ }
2266+
22542267 /**
22552268 * Get object for cached values.
22562269 *
@@ -4574,6 +4587,10 @@ class Player extends Component {
45744587 this . height ( this . audioOnlyCache_ . controlBarHeight ) ;
45754588 }
45764589
4590+ isGlobalHotKeysEnabled ( ) {
4591+ return ! ! ( this . options_ && this . options_ . userActions && this . options_ . userActions . globalHotkeys ) ;
4592+ }
4593+
45774594 enableAudioOnlyUI_ ( ) {
45784595 // Update styling immediately to show the control bar so we can get its height
45794596 this . addClass ( 'vjs-audio-only-mode' ) ;
0 commit comments