I have the following code example that should trigger a warning when the div is in focus and a key is pressed. This does what I expect in IE 7, but not in Firefox 3.5.5. What am I doing wrong?
<html> <head> <title>JS test</title> <script type="text/javascript" src="jquery-1.3.2.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#testdiv").keydown(function(event) { alert("Pressed " + event.keyCode); }); }); </script> <style type="text/css"> #testdiv { width: 50; height: 50; background-color: red; } </style> </head> <body> <div id="testdiv"></div> </body> </html>
EDIT . I just tried replacing keydown with keypress and keyup , and they don't work either. By the way, I also made sure that my Find As You Type setting is turned off just in case.
jquery firefox internet-explorer events keydown
Wayne Koorts Nov 11 '09 at 20:38 2009-11-11 20:38
source share