Make WordPress Core

Opened 8 years ago

Last modified 4 months ago

#19489 reopened enhancement

Consider updating jquery.hotkeys plugin

Reported by: GaryJ Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.3
Component: External Libraries Keywords: needs-patch
Focuses: Cc:
PR Number:


The current version of the jquery.hotkeys plugin in trunk is "(beta)(0.0.3)", where as the latest version (as linked to from the credits screen) is 0.8.

Incidentally, this 0.8 version from tzuryby is credited as being authored by John Resig (and indeed, he appears to have his own repo for it.

Change History (8)

#1 follow-up: @kurtpayne
8 years ago

  • Cc kpayne@… added

It looks like there was a version jump from 0.03 to 0.7. The later version looks like a complete rewrite. As of 0.8, the project was moved to github. I can't find anything about releases 0.4 through 0.6.

The API has changed, too. API as of 0.03:

$.hotkeys.add('Ctrl+C', {options ... }, function() {...});

API as of 0.8:

$(document).bind('keyup', 'Ctrl+C', function() {...});

I tested this on a local installation and was getting some very odd behavior similar to this comment. After some investigation, I wasn't able to discern the root cause.

#2 @GaryJ
8 years ago

For jQuery 1.7+ you should be using on() instead of bind(), but I doubt that would fix the experience you're getting with it.

As both tzuryby and jeresig seem not to be addressing the outstanding issues, it may be worth following up on one of the recently active (one committed yesterday for instance) forks as visible from https://github.com/jeresig/jquery.hotkeys/network.

#4 in reply to: ↑ 1 @SergeyBiryukov
7 years ago

Replying to kurtpayne:

API as of 0.8:

$(document).bind('keyup', 'Ctrl+C', function() {...});

According to the readme and this comment, the correct syntax is this:

$(document).bind('keydown.ctrl_a', fn);

#5 @azaozz
7 years ago

  • Milestone changed from Awaiting Review to Future Release

Perhaps it would be best to also check/refactor table-hotkeys.js (our implementation of the plugin) too. A good initial patch is at http://core.trac.wordpress.org/attachment/ticket/20885/20885.patch.

#6 @vincentastolfi
7 years ago

  • Resolution set to fixed
  • Status changed from new to closed

I have been having trouble getting this plugin to work properly -- it kept binding all the keys at once no matter what key I set. Because of this, hitting any key would trigger my alert "hello." It took two days to find what was wrong, but this code below should work for everyone, where 'S' is the key you chose to keydown (or up) upon:

jQuery(document).bind('keydown', function (e){
	if (String.fromCharCode(e.keyCode) == 'S') {
		return false;

Hope this is helpful to someone!

Last edited 6 years ago by SergeyBiryukov (previous) (diff)

#7 @helen
7 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

#8 @chriscct7
4 years ago

  • Keywords needs-patch added
Note: See TracTickets for help on using tickets.