IEMobile and event.keyCode

L

Larry Newnam

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.
 
H

Henry

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.
 

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

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top