Basically, I use Mr Resig's jQuery Hotkeys plugin to capture and process shortcuts like ctrl+o etc.
OK, maybe I donβt understand the concept, but I got the impression that ctrl+o running anywhere in the document would be captured by the document's hotkey handler.
For example, the following code works in general ...
jQuery(document).bind('keydown', 'ctrl+o', fn);
However, it fails if the user launches the hotkey when it is inside the input field.
It only works if I do the following:
jQuery('body, input').bind('keydown', 'ctrl+o', fn);
This is very bad for my health, since it is associated with binding the damn handler every time a new input field is added to the DOM. Even worse, I have no idea what to bind to in case of complex widgets like CodeMirror.
Don't know if my problem makes sense, maybe I'm using the wrong approach? I also tried to bind to the following objects, but that didn't work: window , document , body , div[contains the whole page]
NB: You can try it here .
jquery dom events hotkeys codemirror
Christian
source share