You are here: Reference > JavaScript > client-side > event handling > properties > repeat (event)

repeat property (event)

Browser support:
Sets or retrieves a Boolean value that indicates whether the onkeydown event is being repeated (a key has been down long enough).
Note that Internet Explorer from version 9 started to support different event objects similarly to Firefox, Opera, Google Chrome and Safari. The event object passed to an event handler and the event object referred to by the window.event property are different in Internet Explorer from version 9 (except if the event handler is registered with the attachEvent method). The repeat property only works for the window.event object, it always contains false for event objects associated with keyboard events (KeyboardEvent). See the example below for details.


You can find the related objects in the Supported by objects section below.
The repeat property is read-only, except if the event object is created with the createEventObject method when it is read/write.

Possible values:

Boolean that indicates whether the onkeydown event is being repeated.
One of the following values:
Event is fired only once.
Event is fired more than once and the onkeyup event is fired meanwhile.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the repeat property:
    <script type="text/javascript">
        function ForbidRepetition (event) {
                // window.event and event differ in IE9 !!!
                // and event.repeat is always false
            if (window.event && 'repeat' in window.event) {
                if (window.event.repeat) {
                    return false;
            else {
                alert ("Your browser does not support this example.");
            return true;
    The repeated key value is canceled.
    <br />
    <input type="text" size="30" value="Hold down any key!" onkeydown="return ForbidRepetition (event);"/>
    <div id="info"></div>
Did you find this example helpful? yes no

Supported by objects:

External links:

User Contributed Comments

Post Content

Post Content