Я хочу прослушивать событие нажатия клавиши iframe в реакции. В моем iframe встроено видео. Теперь, когда видео воспроизводится, я хочу обрабатывать события клавиатуры. Может кто-нибудь помочь мне, как прослушивать события клавиатуры. Это мой код
class VideoDetail extends Component {
videoLoad(e) {
console.log('videoLoaded');
this.videoFrame.addEventListener('keydown',this.onVideoDown);
}
onVideoDown(e) {
console.log('key pressed'); // This is not invoking
}
componentDidMount() {
console.log(this.videoFrame);
}
render() {
const video = this.props.video;
if (!video) {
return Loading...;
}
const videoId = video.id.videoId;
const url = `https://www.youtube.com/embed/${videoId}`;
return (
{url} onLoad={(e) =
{video.snippet.title}
{video.snippet.description}
);
}
}
Подробнее здесь: https://stackoverflow.com/questions/435 ... th-reactjs