I’m trying to do something like:
var keydownHandler = function (ev) {
alert(ev.data.test);
return false;
}
$(document).bind('keydown', {test: 'foo'}, keydownHandler);
But the .bind does not seems to work as it returns null and pressing a key doesn’t fire the handler. Replacing keydown with the "click" eventType, the event handler is correctly registered and works.
My current code uses an anonymous function like this:
var config = ...;
$(document).bind('keydown', config.shortcut, function (e) {
config.click();
e.stopPropagation( );
e.preventDefault( );
}
return false;
} );
It works fine but I have to externalize the anonymous function and I don’t see how I can pass the extra info required by it.
This is because of the hotkeys plugin is loaded which requires the “combi” parameter to be set: