full-screen-keypress.html   [plain text]

<!DOCTYPE html>
    function enterFullScreen() {
        var element = document.getElementById("fullscreen");
        element.innerText = "Press the space bar.";
        var consoleDiv = document.getElementById("console");
        consoleDiv.innerHTML = "<span style='color:red'>FAIL</span>";
        document.addEventListener("keydown", function(event) {
            consoleDiv.innerHTML = "<span style='color:green'>PASS</span>";
        }, true);
        element.addEventListener("webkitfullscreenchange", function(event) {
            if (!document.webkitIsFullScreen)
                element.innerText = "";
        }, false);
<p>This test checks that keyboard events are received by an element in full screen mode. To run the test, press the 'Enter Full Screen' button then press the space bar. The test passes if the element exists full screen and you see the word 'PASS' below.</p>
<button onclick="enterFullScreen()">Enter Full Screen</button>
<div id="fullscreen"></div>
<div id="console"></div>