Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using
JavaScript
$(document).keydown(function (event) {
  alert(event.keyCode);
});

This function works great when the page is loaded..Now when i click on any part of the page and then when i press any key this event is not firing and alert does not come..

Why?
Posted
Updated 7-Nov-12 2:07am
v2
Comments
jim lahey 7-Nov-12 8:20am    
In what browser? I've just tried your code in FireFox and it works
Yes it is working in firefox, IE9 and Chrome latest version.

1 solution

try window
JavaScript
$(window).keydown(function (event) {
  alert(event.keyCode);
});
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900