How do I capture keyboard events while watching an HTML5 video in fullscreen mode?

强颜欢笑 提交于 2019-12-02 04:41:47

Ok I think I have a solution for you... I'm just going to assume you use jQuery for ease of writing this code.

I don't believe you'll be able to capture keyboard events while in Fullscreen mode... but you could do this to get notified when you enter or exit fullscreen mode.

var isVideoFullscreen = video.webkitDisplayingFullscreen;

$(window).bind("resize", function (e) {
    // check to see if your browser has exited fullscreen
    if (isVideoFullscreen != video.webkitDisplayingFullscreen) { // video fullscreen mode has changed
       isVideoFullscreen =  video.webkitDisplayingFullscreen;

       if (isVideoFullscreen) {
            // you have just ENTERED full screen video
       } else {
            // you have just EXITED full screen video
       }
    }
});

Hope this helps or points you in the right direction

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!