By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,474 Members | 1,270 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,474 IT Pros & Developers. It's quick & easy.

Web page function keys

P: n/a
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.

Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Don W." <dNOSPAMwiddersAThotmail.com> wrote:
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
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.