Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8130979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:55:49+00:00 2026-06-06T08:55:49+00:00

I need to know when the user presses the escape key when watching an

  • 0

I need to know when the user presses the escape key when watching an HTML5 video in fullscreen mode. Unfortunately any configured listeners on the document don’t apply since when the user is watching an HTML5 video in fullscreen mode the system focus is on the native video player rather than the browser.

An alternative is listening for when focus reverts back from the native video player to the browser, but I’m unsure as to how I would capture this.

document.addEventListener('keydown', function (e) { console.log(e.keyCode); }, false);

The above successfully logs to the console when I press keys so long as I’m in the browser. As soon as an HTML5 video enters fullscreen mode, the browser obviously can no longer log key codes to the console.

What I’m trying to do is transition from one UI to another after exiting fullscreen mode.

EDIT

Potench’s answer was useful as a starting point which is why I accepted it as that answer despite the following caveats:

  • It only works in Webkit browsers. 🙂
  • As originally defined it does not work since video.webkitDisplayingFullscreen is true whenever the resize event fires.

I got this to work – only on Webkit browsers – by tapping into animation frames to constantly watch for the change in value:

var onFrame, isVideoFullscreen;

onFrame = window.requestAnimationFrame ||
          window.mozRequestAnimationFrame ||
          window.webkitRequestAnimationFrame ||
          window.oRequestAnimationFrame ||
          window.msRequestAnimationFrame ||
          function (fn) {
              setTimeout(fn, 1000 / 60);
          };

isVideoFullscreen = false;

function frame() {
    if (!isVideoFullscreen && video.webkitDisplayingFullscreen) {
        // entered fullscreen mode
        isVideoFullscreen = true;
    } else if (isVideoFullscreen && !video.webkitDisplayingFullscreen) {
        // exited fullscreen mode
        isVideoFullscreen = false;
    }
    onFrame(frame);
}
onFrame(frame);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T08:55:51+00:00Added an answer on June 6, 2026 at 8:55 am

    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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my application I need to know the user's Facebook uid. I get by
I need to know if the user has hidden an icon added by my
I need to know which views does a user have which privileges on. I'm
I need to know the ID of the current user in a model: def
I need to know by notification or whatever when the user press outside the
I need to know when a WPF Datagrid has been sorted by the user.
I am using Jquery to animate an object while the user presses a key.
Is it possible to run a method every time the user presses a key.
Need to know this so that i could send DTMF and that is going
Need to know which event triggered after text selection done in Apple iPad. It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.