prototype/javascript - firefox not firing keypress/keydown event unless focus is in textbox
Posted
by Chloraphil
on Stack Overflow
See other posts from Stack Overflow
or by Chloraphil
Published on 2009-03-10T13:55:01Z
Indexed on
2010/05/24
23:21 UTC
Read the original article
Hit count: 383
The following works fine on IE6, IE7, and chrome. Not working on ff 3.0.7.
<html><head>
<script src="prototype.js" type="text/javascript" ></script>
<script type="text/javascript">
Event.observe(window, 'load',
function(){
Event.observe(document.body, 'keydown', myEventHandler);
alert('window load');
});
function myEventHandler(evt) {
alert(evt);
}
</script>
</head>
<body >
<input type="text" /><br><br>
</body></html>
EDIT: By "not working" I mean myEventHandler is not firing in firefox.
EDIT2: Furthermore, it works fine when focus is on the input element. I want it fire for all keydowns.
© Stack Overflow or respective owner