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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

arrow key event in Javascript

Status
Not open for further replies.

arunjp

Programmer
Jan 10, 2001
29
US
Hi !
How to get the key code in javascript for four arrow keys with in a form text field, that should work in netscape 4.x . It is urgent.

Thanks
AJP
 
if it's that urgent maybe you could reformulate your question so that we understand it ?
 
Hi All,
I have similar problem. This is my function:

<script LANGUAGE=&quot;JavaScript1.2&quot;>
function IEKey() {
if (window.event.keyCode == 90)
{alert('That\'s the Z key')};
if (window.event.keyCode == 5)
{alert('That\'s the UpArrow key')};
}
</script>

Works for the Z key but not for the UpArrow key.

Suggestions, please?
mansii
 
I had no problem with IE 6:

<label id=&quot;lblout&quot;>jj</label>
<script LANGUAGE=&quot;JavaScript1.2&quot;>
function IEKey() {
// make and set an array for text output:
var arr = new Array();
arr[arr.length] = &quot;keyCode is: &quot; + event.keyCode + &quot;<br>&quot;;
arr[arr.length] = &quot;ctrlKey is: &quot; + event.ctrlKey + &quot;<br>&quot;;
arr[arr.length] = &quot;shiftKey is: &quot; + event.shiftKey + &quot;<br>&quot;;
arr[arr.length] = &quot;altKey is: &quot; + event.altKey + &quot;<br><br>&quot;;
arr[arr.length] = &quot;<h1>Property and event list:</h1>&quot; + &quot;<br>&quot;;
for(hh in event){
arr[arr.length] = hh + &quot;<br>&quot;;
}
if(event.keyCode==38){
alert(&quot;keyup&quot;);
}
document.getElementById('lblout').innerHTML=arr.join(&quot;&quot;);
}
document.onkeyup = IEKey;
</script>
 
For arunjp, this should work:
<script>
NN = (document.all) ? 0 : 1;
function MouseDown(e) {
if (NN) {
// Netscape code here e is event
} else {
// IE code here, event is event (like event.srcElement)
}
}
if (NN) {
document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
}
document.onmousedown = MouseDown;
</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top