Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

detect ENTER keypress and click on button in address bar

Status
Not open for further replies.

newbiegalore

Programmer
Apr 12, 2008
8
US
Hello everyone Smile
I have just finished going through some tutorials on developing extensions for mozilla and have made a version of the born-geek toolbar. Being a newbie I am stuck at a relatively simple-sounding problem and would greatly appreciate any pointers/examples..

The problem: I want to detect an ENTER keypress.
Why: I am developing an extension which should say the site yu are visiting is xyz.com. I can pick up the main URL using alert(window.content.document.location.href); but then I need to send it to my server and receive a reply back. I want to pick up the URL only when an ENTER is pressed or when the user clicks on the GO in the address bar.

Can someone please point me to a solution?

I can't understand who should call the function which analyzes the keypress, it seems asif it should run in the "background" all the time, the same goes for analyzing the
click on the GO button on the address bar. Is there a standard name for the Go button which I can use to access it and find if it has been pressed?

Thanks!
 
OK got it.. I used ..

function kH(e) {
var pK = e? e.which: window.event.keyCode;
if (pK == 13 ){
alert('Enter was pressed');
}
}

document.onkeypress = kH;
from:
Can someone please point me to how to understand if the "go" button in the address bar has been clicked. The go button is the one where the following tooltip is displayed "Go to the address in the Location Bar"

Thanks,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top