@@ -370,6 +370,8 @@ class Player extends Component {
370
370
371
371
this . boundUpdatePlayerHeightOnAudioOnlyMode_ = ( e ) => this . updatePlayerHeightOnAudioOnlyMode_ ( e ) ;
372
372
373
+ this . boundGlobalKeydown_ = ( e ) => this . handleGlobalKeydown_ ( e ) ;
374
+
373
375
// default isFullscreen_ to false
374
376
this . isFullscreen_ = false ;
375
377
@@ -611,6 +613,10 @@ class Player extends Component {
611
613
this . on ( 'keydown' , ( e ) => this . handleKeyDown ( e ) ) ;
612
614
this . on ( 'languagechange' , ( e ) => this . handleLanguagechange ( e ) ) ;
613
615
616
+ if ( this . isGlobalHotKeysEnabled ( ) ) {
617
+ Events . on ( document . body , 'keydown' , this . boundGlobalKeydown_ ) ;
618
+ }
619
+
614
620
this . breakpoints ( this . options_ . breakpoints ) ;
615
621
this . responsive ( this . options_ . responsive ) ;
616
622
@@ -646,6 +652,7 @@ class Player extends Component {
646
652
// Make sure all player-specific document listeners are unbound. This is
647
653
Events . off ( document , this . fsApi_ . fullscreenchange , this . boundDocumentFullscreenChange_ ) ;
648
654
Events . off ( document , 'keydown' , this . boundFullWindowOnEscKey_ ) ;
655
+ Events . off ( document . body , 'keydown' , this . boundGlobalKeydown_ ) ;
649
656
650
657
if ( this . styleEl_ && this . styleEl_ . parentNode ) {
651
658
this . styleEl_ . parentNode . removeChild ( this . styleEl_ ) ;
@@ -2247,6 +2254,12 @@ class Player extends Component {
2247
2254
this . trigger ( 'textdata' , data ) ;
2248
2255
}
2249
2256
2257
+ handleGlobalKeydown_ ( event ) {
2258
+ if ( event . target === document . body ) {
2259
+ this . handleKeyDown ( event ) ;
2260
+ }
2261
+ }
2262
+
2250
2263
/**
2251
2264
* Get object for cached values.
2252
2265
*
@@ -4570,6 +4583,10 @@ class Player extends Component {
4570
4583
this . height ( this . audioOnlyCache_ . controlBarHeight ) ;
4571
4584
}
4572
4585
4586
+ isGlobalHotKeysEnabled ( ) {
4587
+ return ! ! ( this . options_ && this . options_ . userActions && this . options_ . userActions . globalHotkeys ) ;
4588
+ }
4589
+
4573
4590
enableAudioOnlyUI_ ( ) {
4574
4591
// Update styling immediately to show the control bar so we can get its height
4575
4592
this . addClass ( 'vjs-audio-only-mode' ) ;
0 commit comments