You're right, Anton, it's onkeydown.  Sorry about that.  Now, keeping the
browser from doing it's own thing is one of the hard parts, and it's
different on different browsers.  For IE, I set the key code in the event to
zero and return false from the event handler.  Netscape is different on just
about every release, and I still don't have a standard approach for it.

Joe


> -----Original Message-----
> From: web400-admin@midrange.com [mailto:web400-admin@midrange.com]On
> Behalf Of Anton Gombkötö
> Sent: Wednesday, August 14, 2002 3:52 PM
> To: web400@midrange.com
> Subject: RE: [WEB400] Customer Service -- Online
>
>
>
> > > Could you share that piece of JavaScript or post a link on
> how to learn to
> > > map keys from the broswer?
> >
> >It depends on what you plan to do with the fkeys, but in
> general, you need
> >an onkeypress function that looks something like this:
> >
> >   fnkey = -1;
> >   if ((key >= 112) && (key <= 123)) fnkey = key-111;
> >   if (window.event.shiftKey && fnkey > 0  && fnkey < 13) fnkey += 12;
> >
> >   if (fnkey > -1)
> >   {
> >     // An FKEY was pressed, and the key (1-24) is in fnkey
> >     (...)
> >   }
>
> Thanks Joe,
>
> i managed to make it work somehow, but i noticed the following:
>
> onKeyPress catches all but function keys. I had to use onKeyDown.
>
> i had to include that before the first use of variable "key":
>
> key = window.event.keyCode;
>
> But.... how do you prevent MS IE from taking its own action when a user
> presses e.g. F1, F4, F5, F10, F11 (whether shifted or unshifted)?
>
>
> for those interested - this works in IE 6.0 on my PC (PC = Personal
> Configuration :-)
>
> <html><head><title>Test</title>
>
> <script language="JavaScript" type="text/javascript">
> <!--
> function fkey() {
>    key = window.event.keyCode;
>    fnkey = -1;
>    if ((key >= 112) && (key <= 123)) fnkey = key-111;
>    if (window.event.shiftKey && fnkey > 0  && fnkey < 13) fnkey += 12;
>
>
>    if (fnkey > -1)
>    {
>      // An FKEY was pressed, and the key (1-24) is in fnkey
>      alert ('F' + fnkey);
>    }
> }
> //-->
> </script>
> </head><body onKeyDown="fkey()">
>
> press a key...
>
>
> </body></html>
>
>
> Thanks in advance!
>
>
> best regards /  Mit freundlichen Grüssen
>
> Anton Gombkötö
> Avenum Technologie GmbH
>
> http://www.avenum.com
>
> _______________________________________________
> This is the Web Enabling the AS400 / iSeries (WEB400) mailing list
> To post a message email: WEB400@midrange.com
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/cgi-bin/listinfo/web400
> or email: WEB400-request@midrange.com
> Before posting, please take a moment to review the archives
> at http://archive.midrange.com/web400.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.