@@ -370,6 +370,8 @@ class Player extends Component {
370370
371371 this . boundUpdatePlayerHeightOnAudioOnlyMode_ = ( e ) => this . updatePlayerHeightOnAudioOnlyMode_ ( e ) ;
372372
373+ this . boundGlobalKeydown_ = ( e ) => this . handleGlobalKeydown_ ( e ) ;
374+
373375 // default isFullscreen_ to false
374376 this . isFullscreen_ = false ;
375377
@@ -611,6 +613,10 @@ class Player extends Component {
611613 this . on ( 'keydown' , ( e ) => this . handleKeyDown ( e ) ) ;
612614 this . on ( 'languagechange' , ( e ) => this . handleLanguagechange ( e ) ) ;
613615
616+ if ( this . isGlobalHotKeysEnabled ( ) ) {
617+ Events . on ( document . body , 'keydown' , this . boundGlobalKeydown_ ) ;
618+ }
619+
614620 this . breakpoints ( this . options_ . breakpoints ) ;
615621 this . responsive ( this . options_ . responsive ) ;
616622
@@ -646,6 +652,7 @@ class Player extends Component {
646652 // Make sure all player-specific document listeners are unbound. This is
647653 Events . off ( document , this . fsApi_ . fullscreenchange , this . boundDocumentFullscreenChange_ ) ;
648654 Events . off ( document , 'keydown' , this . boundFullWindowOnEscKey_ ) ;
655+ Events . off ( document . body , 'keydown' , this . boundGlobalKeydown_ ) ;
649656
650657 if ( this . styleEl_ && this . styleEl_ . parentNode ) {
651658 this . styleEl_ . parentNode . removeChild ( this . styleEl_ ) ;
@@ -2247,6 +2254,12 @@ class Player extends Component {
22472254 this . trigger ( 'textdata' , data ) ;
22482255 }
22492256
2257+ handleGlobalKeydown_ ( event ) {
2258+ if ( event . target === document . body ) {
2259+ this . handleKeyDown ( event ) ;
2260+ }
2261+ }
2262+
22502263 /**
22512264 * Get object for cached values.
22522265 *
@@ -4570,6 +4583,10 @@ class Player extends Component {
45704583 this . height ( this . audioOnlyCache_ . controlBarHeight ) ;
45714584 }
45724585
4586+ isGlobalHotKeysEnabled ( ) {
4587+ return ! ! ( this . options_ && this . options_ . userActions && this . options_ . userActions . globalHotkeys ) ;
4588+ }
4589+
45734590 enableAudioOnlyUI_ ( ) {
45744591 // Update styling immediately to show the control bar so we can get its height
45754592 this . addClass ( 'vjs-audio-only-mode' ) ;
0 commit comments