mozilla
Your Search Results

    Window.onkeypress

    This article is in need of a technical review.

    Summary

    An event handler for the keypress event on the window.

    Syntax

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

    Example

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

    Notes

    The keypress event is raised when the user presses and releases any key on the keyboard.

    • Under FF 1.0.5.4 this event fires before the keyup event is detected, i.e. it appears to work exactly like onkeydown.

    Specification

    Not part of specification.

    Document Tags and Contributors

    Last updated by: fscholz,
    Hide Sidebar