IEMobile and event.keyCode

Discussion in 'Javascript' started by Larry Newnam, Jan 10, 2008.

  1. Larry Newnam

    Larry Newnam Guest

    Goal: My user will have an RF gun (scan gun with keys) running a
    simple app in IEMobile. I need to know when they press a function key
    (like F8).

    This does not work for me:
    document.onkeydown = function getcode(ev) {
    value = (window.external) ? event.keyCode : ev.keyCode;
    alert(value);
    }

    Does anyone know of an alternative way to capture the event in
    IEMobile?

    Expect lavish praise if you can figure this out - that's all I can
    offer really.
     
    Larry Newnam, Jan 10, 2008
    #1
    1. Advertising

  2. Larry Newnam

    Henry Guest

    On Jan 10, 4:16 pm, Larry Newnam wrote:
    > Goal: My user will have an RF gun (scan gun with keys)
    > running a simple app in IEMobile. I need to know when
    > they press a function key
    > (like F8).
    >
    > This does not work for me:
    > document.onkeydown = function getcode(ev) {
    > value = (window.external) ? event.keyCode : ev.keyCode;

    ^^^^^^^^^^^^^^^
    Why the insane object inference? What is the relationship you are
    proposing between whether the browser's window object has an -
    external - property with trueness and the handling of event objects?

    > alert(value);
    >
    > }
    >
    > Does anyone know of an alternative way to capture the event in
    > IEMobile?
    >
    > Expect lavish praise if you can figure this out - that's all I can
    > offer really.


    The odds are pretty good that your IE mobile browser does not have a -
    window.external - object and that silly inference alone is your
    problem. The normal cross browser handling for event objects is to
    normalize the event object (function parameter vs. global event
    reference) with:-

    ev = ev || window.event;

    - and then read the key code from that normalised object:-

    value = ev.keyCode;

    In the event that IE mobile does not provide a - keyCode - property
    you might try looking up older alternatives. And also try other events
    such as keypress and keyup.
     
    Henry, Jan 10, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marvin Massih

    "Keycode DLL not found or invalid keycode"

    Marvin Massih, Dec 31, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    2,134
    Marvin Massih
    Dec 31, 2004
  2. Nathan Sokalski
    Replies:
    4
    Views:
    4,180
    Nathan Sokalski
    Mar 11, 2006
  3. Nathan Sokalski

    Determining the Browser and event.keyCode vs. event.which

    Nathan Sokalski, Mar 10, 2006, in forum: ASP .Net Building Controls
    Replies:
    4
    Views:
    177
    Nathan Sokalski
    Mar 11, 2006
  4. B

    IEMOBILE and javascript

    B, May 28, 2006, in forum: ASP .Net Mobile
    Replies:
    0
    Views:
    710
  5. Daan

    onchange event in IEMobile

    Daan, May 31, 2008, in forum: Javascript
    Replies:
    1
    Views:
    125
Loading...

Share This Page