469,323 Members | 1,198 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

Problem capturing return key (keycode = 13) in Firefox

Hi,

I have a small JavaScript code in a page to trap when user presses Return key.

My problem is that if you visit the page and then enter a different url in address field, and press Return, that key press is also being captured. How can I distinguish when user is pressing Return on the address field in address bar?

Works ok on IE, the problem appears only in Firefox.

This is the code I have:

Expand|Select|Wrap|Line Numbers
  1. document.onkeyup = HandleKeyup;
  2.  
  3. function HandleKeyup(e){
  4.    if(!e){
  5.      e = window.event;
  6.  }
  7.  if(e.keyCode == 13){
  8.     SomeFunction();
  9.  }
  10. }
Thanks!
Veronica
Dec 5 '06 #1
2 8784
pshm
20
Expand|Select|Wrap|Line Numbers
  1. document.onkeyup = HandleKeyup;
  2.  
  3. function HandleKeyup(e){
  4.    if(!e){
  5.      e = window.event;
  6.  }
  7.  if(e.which == 13){
  8.     SomeFunction();
  9.  }
  10. }
  11.  
Mar 27 '08 #2
mrhoo
428 256MB
The address bar is not in the document, so I'm not sure how IE is capturing it, either.
Mar 27 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Greg | last post: by
6 posts views Thread by Robert Nurse | last post: by
7 posts views Thread by jerrygarciuh | last post: by
6 posts views Thread by rich_poppleton | last post: by
3 posts views Thread by Muriel | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.