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!

Ascii function for netscape? 1

Status
Not open for further replies.

FRANDAZZO

Programmer
Nov 29, 2000
60
US
Hi, I wanted to know if there is a Ascii function for the netscape browser. I know for IE in vbscript I can use the keyascii function or in javascript the window.event.keycode to find out what key on the keyboard the user pressed. Does netscape using javascript have some sort of function I can use.

thanks
 
ns4 = (document.layers)?true:false;
ie4 = (document.all)?true:false;

function keyDown(e)
{
if(ns4){var keyhit=e.which;}
if(ie4){var keyhit=event.keyCode;}
if(keyhit==13)
{
document.formname.submit()
}
}

document.onkeydown = keyDown
if (ns4) document.captureEvents(Event.KEYDOWN) adam@aauser.com
 
I copied the follwing code from: It tells you which key you pressed and it's value(for netscape). That's the way you should do it:
<HTML>
<HEAD>
<TITLE>The Dynamic Duo - Capturing Keystrokes (Netscape)</TITLE>
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!--

function keyDown(e) {
var keycode = e.which
var realkey = String.fromCharCode(e.which)
alert(&quot;keycode: &quot; + keycode + &quot;\nrealkey: &quot; + realkey)
}

document.onkeydown = keyDown
document.captureEvents(Event.KEYDOWN)

//-->
</SCRIPT>
</HEAD>

<BODY BGCOLOR=&quot;#FFFFFF&quot;>

Press a key

</BODY>
</HTML>
 
For your needs, I edited the following code when I'm based on: It tells you which key you pressed and it's value(for netscape). That's the way you should do it:
<HTML>
<HEAD>
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!--

function KeyPress(e) {
var keycode = e.which
var realkey = String.fromCharCode(e.which)
alert(&quot;keycode: &quot; + keycode + &quot;\nrealkey: &quot; + realkey)
}

window.captureEvents(Event.KEYPRESS);
window.onKeyPress = KeyPress;

//-->
</SCRIPT>
</HEAD>

<BODY BGCOLOR=&quot;#FFFFFF&quot;>

Press a key

</BODY>
</HTML>
 
Sorry for the doubled msgs, It was ment to be one.
Just the second.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top