Opened 18 months ago
Last modified 4 months ago
#19489 reopened enhancement
Consider updating jquery.hotkeys plugin
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Future Release |
| Component: | External Libraries | Version: | 3.3 |
| Severity: | normal | Keywords: | |
| Cc: | kpayne@… |
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)
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:3
SergeyBiryukov — 12 months ago
Related: #20885
comment:4
in reply to:
↑ 1
SergeyBiryukov — 12 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);
- 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
vincentastolfi — 4 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!

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.