WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 8 months ago

#19489 reopened enhancement

Consider updating jquery.hotkeys plugin

Reported by: GaryJ Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.3
Component: External Libraries Keywords:
Focuses: Cc:

Description

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

comment:1 follow-up: kurtpayne2 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.

comment:2 GaryJ2 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.

comment:4 in reply to: ↑ 1 SergeyBiryukov23 months 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);

comment:5 azaozz23 months 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.

comment:6 vincentastolfi15 months 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') {
		alert('hello');
		e.preventDefault();
		return false;
	}
});

Hope this is helpful to someone!

Last edited 8 months ago by SergeyBiryukov (previous) (diff)

comment:7 helen15 months ago

  • Resolution fixed deleted
  • Status changed from closed to reopened
Note: See TracTickets for help on using tickets.