Skip to content

.keypress vs .keydown Description on the jQuery API Documentation #278

@Kelderic

Description

@Kelderic

Regarding .keypress and .keydown, the jQuery API documentation currently says:

The keypress event is sent to an element when the browser registers keyboard input. This is similar to the keydown event, except in the case of key repeats. If the user presses and holds a key, a keydown event is triggered once, but separate keypress events are triggered for each inserted character. - http://api.jquery.com/keypress/

I've been testing this, and I've found that on modern browsers, .keydown continues to fire if a key is held down. I've tested in IE9-10, and current versions of Chrome and Firefox. After posting in the jQuery forums, another user verified with this jsFiddle:

http://jsfiddle.net/fiddleyetu/DWM8N/

The API needs to be updated to reflect that .keydown does fire continuously. We should also mention that .keypress doesn't fire when a user hits backspace or delete, even though that is changing the text inside the textarea/input.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions