Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Firefox and keydown event inside DIV elements
Old 07-22-2005, 07:29 AM Firefox and keydown event inside DIV elements
Junior Talker

Posts: 4
Trades: 0
Hello,
can anybody please explain to me why the following code does not work in Firefox as it does in IE?
In general, how can I capture keydown events inside DIVs with firefox?

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>keydown test</title>
</head>
<script language="JavaScript" type="text/javascript">
function keydown(evt)
{
     obj = document.getElementById("test");
     if(obj)
     {
          if(window.event)
               var key = evt.keyCode;
          else if(evt.which)
               var key = evt.which;
          else
               return true;
          obj.innerHTML += "user pressed '"+String.fromCharCode(key)+"' ("+key+")<br>";
     }
}
</script>
<body>
<div id="test" style="border: 1px solid black; padding: 8px; position: absolute; overflow: visible; left: 0px; top: 0px; -moz-box-sizing: border-box; width:400px; height:100px; font-family:tahoma; font-size:11px; background-color:#CCCC66;" onkeydown="return keydown(event);">
</div>
</body>
</html>
Thanks in advance.
AsGoodAsItGets is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to Firefox and keydown event inside DIV elements
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.44902 seconds with 12 queries