Jquery hotkeys behaviour

I am a fairly decent javascript programmer, but do not have a deep understanding of the DOM, this question should be fairly simple for any good programer, I hope.

I am trying to use the Jquery.Hotkeys lib. here’s what I noticed:

if I do:

$(document).ready( function(){
$(document).bind('keydown', 'ctrl+q', alertworld);
});

It works perfectly. but when I do

$(document).bind('keydown', 'ctrl+q', alertworld);

It binds every single keydown press to the alertworld function. I just want to understand why it behaves so. I imagined it should work just fine in the second code example. Please help. thanx in anticipation

The tests that I tried seem to trigger on keydown correctly for both occasions.

The only reason why it would trigger incorrectly is if the binding occurs before the hotkeys library has loaded.

Thanks a lot Paul,

I was confused at the behaviour, and yes you are right… i moved the line that included the jquery.hotkeys Script some lines higher… and the error stoped…

I really appreciate your help.