Basically, I'm using jQuery Hotkeys plugin by Mr Resig to capture and handle shortcuts like ctrl+o
etc...
OK, maybe I don't uderstand the concept, but I was under the impression that a ctrl+o
triggered anywhere inside the document will be captured by a document hotkey handler.
For example, the following code works in general...
jQuery(document).bind('keydown', 'ctrl+o', fn);
However, it fails miserably if the user triggers the hotkey when inside an input box.
It only works if I do the following:
jQuery('body, input').bind('keydown', 'ctrl+o', fn);
Which is pretty bad for my health since it involves binding the damn handler each time a new input box is added to the DOM. Worse still, I have no idea what to bind to in the case of complex widgets like CodeMirror.
Dunno if my problem makes sense, perhaps I'm using the wrong approach? I also tried binding to the following objects, but it didn't work: window
, document
, body
, div[contains the whole page]
NB: You can try it out here.