Skip to main content

Bug Tracker

Side navigation

#8296 closed bug (patchwelcome)

Opened February 16, 2011 02:36PM UTC

Closed February 17, 2011 01:21PM UTC

Last modified March 14, 2012 11:41AM UTC

Keydown triggers repeatedly on Chrome/Safari

Reported by: rodrigo@layers.com Owned by:
Priority: low Milestone: 1.next
Component: event Version: 1.5
Keywords: Cc:
Blocked by: Blocking:
Description

jQuery version: 1.5

Browsers: Safari Versión 5.0.3 (6533.19.4), Chrome 9.0.597.102

OS: Mac OS X 10.6.6

Step-by-step Instructions: check Test case and hold a key in jsfiddle's result window.

Description: According to http://api.jquery.com/keypress/ 'If the user presses and holds a key, a keydown event is triggered once'. So, I expect that to happen. I do not expect it to trigger more than once. This is happening in Chrome and in Safari. It does not happen in Firefox.

Test case: http://jsfiddle.net/29gJ4/1/

Attachments (0)
Change History (4)

Changed February 16, 2011 09:48PM UTC by dmethvin comment:1

Seems like it's outside jQuery:

http://jsfiddle.net/dmethvin/29gJ4/4/

Perhaps we just want to change the docs. It appears this behavior varies not only by browser but possibly by platform:

http://unixpapa.com/js/key.html

Changed February 17, 2011 01:21PM UTC by jitter comment:2

component: unfiledevent
priority: undecidedlow
resolution: → patchwelcome
status: newclosed

You can also check http://quirksmode.org/dom/events/keys.html or just google for any code/plugin (doesn't need to be jQuery related) that handles or tries to handle keyboard events cross-browser.

Afaik the keydown/-press/-up events aren't covered by a specification. Thus the actual behavior differs between browsers, same browser but different versions, platforms, ...

So probably this was just an oversight when the docs where written (e.g. maybe some quick tests where only done in FF or similar)

So this isn't really fixable with a reasonable amout of code. But if you are willing to try and normalize keyevent behavior crossbrowser and provide it as a patch (pull request on github) that could be considered for inclusion in a future jQuery version.

Changed February 17, 2011 01:21PM UTC by jitter comment:3

keywords: → needsdocs

Changed February 26, 2011 05:59AM UTC by addyosmani comment:4

keywords: needsdocs

I've updated the keypress docs to highlight the lack of consistent cross-browser support for this (something along the lines of what jitter said above).