Click here to Skip to main content
Sign Up to vote bad
good
I am using
$(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 7 Nov '12 - 2:06
Edited 7 Nov '12 - 2:07

Comments
jim lahey - 7 Nov '12 - 8:20
In what browser? I've just tried your code in FireFox and it works
Tadit Dash - 7 Nov '12 - 9:13
Yes it is working in firefox, IE9 and Chrome latest version.

1 solution

try window
$(window).keydown(function (event) {
  alert(event.keyCode);
});
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 OriginalGriff 228
1 Ron Beyer 220
2 Mahesh Bailwal 215
3 Rohan Leuva 210
4 Sergey Alexandrovich Kryukov 162
0 Sergey Alexandrovich Kryukov 8,548
1 OriginalGriff 6,819
2 CPallini 3,648
3 Rohan Leuva 2,933
4 Maciej Los 2,288


Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 20 Nov 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid