$(document).keydown event not triggered/caught on first click
For some reason the very first time the user presses a key on the HTML page the click is not registered. But if I click one time or press a key then the second time I press a key it registers fine. Here is how the event handler is declared:
- .....................
- $(function()
- {
- .......................
- ......................
- $(document).keydown(function(e)
- {
- alert('keydown event');
- ...................................
- ..................................
- // Other stuff
The outcome of the code above is that the first time I press a key nothing happens. The second time I press a key I get the Alert statement 'keydown event'. Why is that?