<!DOCTYPE html>
<html lang="cs">
<head>
    <meta charset="utf-8" />
    <title>Postřeh</title>
 
    <style>
        body {background-color: red}
 
        #vysledek {
            font-size: 200%;
            font-weight: bold;
            position: absolute;
            left: 50%;
            top: 50%;
            -webkit-transform: translate(-50%, -50%);
            transform: translate(-50%, -50%);
        }
    </style>
 
    <script>
    /* <![CDATA[ */
    /* Sem prijde javascript kod */
 
    let casA
    let casB
 
    setTimeout( function(){
        casA = new Date()
        document.body.style.backgroundColor = "green"
    }, 5000 + 5000 * Math.random())
 
    function klavesa(event){
        if(event.code == 'Space'){
            casB = new Date()
            document.getElementById('vysledek').innerHTML = (casB - casA)+"ms"
        }
    }
    document.addEventListener("keydown", klavesa);
 
    /* ]]> */
    </script>
</head>
 
<body>
    <div id="vysledek"></div>
 
</body>
</html>