mozilla
Your Search Results

    Window.onkeydown

    Summary

    An event handler for the keydown event on the window.

    Syntax

    window.onkeydown = funcRef;
    
    • funcRef is a reference to a function.

    Example

    window.onkeydown = doFunc;
    
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8" />
    <title>onkeydown test</title>
    
    <script>
    window.onkeydown = keydown;
    
    function keydown() {
      alert("keydown event detected!");
    }
    </script>
    
    </head>
    <body>
    <p>press and hold down any key to fire the keydown event.</p>
    </body>
    </html>
    

    Notes

    The keydown event is raised when the user presses any key.

    Specification

    Not part of specification.

    Document Tags and Contributors

    Contributors to this page: Sheppy, fscholz, SphinxKnight, LibreGeekingKid, ethertank, Rappo, Jabez, teoli
    Last updated by: fscholz,
    Hide Sidebar