Bug Tracker

Opened 12 years ago

Closed 12 years ago

Last modified 11 years ago

#8296 closed bug (patchwelcome)

Keydown triggers repeatedly on Chrome/Safari

Reported by: [email protected] 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/

Change History (4)

comment:1 Changed 12 years ago by dmethvin

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

comment:2 Changed 12 years ago by jitter

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.

comment:3 Changed 12 years ago by jitter

Keywords: needsdocs added

comment:4 Changed 12 years ago by addyosmani

Keywords: needsdocs removed

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).

Note: See TracTickets for help on using tickets.