Web page function keys

D

Don W.

I need to use some function keys as speed-keys (instead of clicking a button
with the mouse.) Using this code doesn't display any codes for the function
keys:

<html><body>
<SCRIPT LANGUAGE="JavaScript">
document.onkeypress = Check_key;

function Check_key()
{
whichKey = String.fromCharCode(event.keyCode).toLowerCase();
alert(whichKey);
}

</SCRIPT>
</body></html>

How can I capture the pressing of the function keys?

Don W.
 
E

Erwin Moller

Don W. said:
I need to use some function keys as speed-keys (instead of clicking a
button
with the mouse.) Using this code doesn't display any codes for the
function keys:

<html><body>
<SCRIPT LANGUAGE="JavaScript">
document.onkeypress = Check_key;

function Check_key()
{
whichKey = String.fromCharCode(event.keyCode).toLowerCase();
alert(whichKey);
}

</SCRIPT>
</body></html>

How can I capture the pressing of the function keys?

Don W.

Hi Don,

You didn't pass Event to the function...
And use Event.which
The following code works fine under Mozilla 1.4

<SCRIPT LANGUAGE="JavaScript">
document.onkeypress = Check_key;

function Check_key(Event)
{
whichKey = String.fromCharCode(Event.which).toLowerCase();
alert(whichKey);
}
</SCRIPT>

Good luck,

Reagrds,
Erwin Moller
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,102
Messages
2,570,645
Members
47,245
Latest member
ShannonEat

Latest Threads

Top