Bug Tracker

Ticket #8296 (closed bug: patchwelcome)

Opened 3 years ago

Last modified 2 years ago

Keydown triggers repeatedly on Chrome/Safari

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

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

comment:1 Changed 3 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 3 years ago by jitter

  • Priority changed from undecided to low
  • Resolution set to patchwelcome
  • Status changed from new to closed
  • Component changed from unfiled to event

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 3 years ago by jitter

  • Keywords needsdocs added

comment:4 Changed 3 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.