diff --git a/src/components/play-pause/play-pause.tsx b/src/components/play-pause/play-pause.tsx index 7c5d4c5f2..6488a9b22 100644 --- a/src/components/play-pause/play-pause.tsx +++ b/src/components/play-pause/play-pause.tsx @@ -63,6 +63,8 @@ class PlayPause extends Component { this._playPauseButtonRef?.focus(); }); }); + const targetId: HTMLDivElement | Document = (document.getElementById(this.props.player.config.targetId) as HTMLDivElement) || document; + eventManager.listen(targetId,'keydown', this.handleSpaceKey); } /** @@ -77,6 +79,13 @@ class PlayPause extends Component { this.props.notifyClick(); }; + handleSpaceKey = (event) => { + if (event.code === 'Space') { + this.togglePlayPause(); + event.preventDefault(); + } + } + /** * render component *