Hello,

I want to determine which key is pressed in a editbox on a page hosted by
our own webserver. However on Windows Mobile 2003 the onKeypress event is
not triggered. Does anybody know why this code isn't working properly? If I
replace the onKeypress by onFocus the JavaScript is executed and an alert is
shown.

Kind regards,
H. Donkers

<HTML>
<HEAD>
<script language=JavaScript>

function ShowKey(){
alert('A key is pressed');
}
</script>
</HEAD>

<BODY>
TEST
<FORM>
<input type="TEXT" name="EDIT1" id="edit1" onKeypress="ShowKey()">
</FORM>

</BODY>

</HTML>

RE: Windows mobile 2003 JavaScript OnKeyPress by michael

michael
Fri Dec 03 05:39:07 CST 2004

I couldn't make it work either, but found a dirty workaround

On the Editbox, handle those two events

OnFocus: call a function that starts a timer (set the timeout to 200 ms)
OnUnfocus: clear the timer

The timer calls another function, which checks if the value of the edit box
has changed. If yes, voila, there was a key pressed and you can handle it.

If any one has a clean solution to that, I am very interested as well. But
at least this one works for me.

Michael

"Harm Donkers" wrote:

> Hello,
>
> I want to determine which key is pressed in a editbox on a page hosted by
> our own webserver. However on Windows Mobile 2003 the onKeypress event is
> not triggered. Does anybody know why this code isn't working properly? If I
> replace the onKeypress by onFocus the JavaScript is executed and an alert is
> shown.
>
> Kind regards,
> H. Donkers
>
> <HTML>
> <HEAD>
> <script language=JavaScript>
>
> function ShowKey(){
> alert('A key is pressed');
> }
> </script>
> </HEAD>
>
> <BODY>
> TEST
> <FORM>
> <input type="TEXT" name="EDIT1" id="edit1" onKeypress="ShowKey()">
> </FORM>
>
> </BODY>
>
> </HTML>
>
>
>

Re: Windows mobile 2003 JavaScript OnKeyPress by Stephen

Stephen
Sat Dec 04 21:15:47 CST 2004

As far as I know onKeyPress is not supported.

onChange is supported and could be used for a wordaround.

Stephen.
"michael" <michael@discussions.microsoft.com> wrote in message
news:A6F08FE8-E233-4581-917E-D89F51031BD7@microsoft.com...
> I couldn't make it work either, but found a dirty workaround
>
> On the Editbox, handle those two events
>
> OnFocus: call a function that starts a timer (set the timeout to 200 ms)
> OnUnfocus: clear the timer
>
> The timer calls another function, which checks if the value of the edit
box
> has changed. If yes, voila, there was a key pressed and you can handle it.
>
> If any one has a clean solution to that, I am very interested as well. But
> at least this one works for me.
>
> Michael
>
> "Harm Donkers" wrote:
>
> > Hello,
> >
> > I want to determine which key is pressed in a editbox on a page hosted
by
> > our own webserver. However on Windows Mobile 2003 the onKeypress event
is
> > not triggered. Does anybody know why this code isn't working properly?
If I
> > replace the onKeypress by onFocus the JavaScript is executed and an
alert is
> > shown.
> >
> > Kind regards,
> > H. Donkers
> >
> > <HTML>
> > <HEAD>
> > <script language=JavaScript>
> >
> > function ShowKey(){
> > alert('A key is pressed');
> > }
> > </script>
> > </HEAD>
> >
> > <BODY>
> > TEST
> > <FORM>
> > <input type="TEXT" name="EDIT1" id="edit1" onKeypress="ShowKey()">
> > </FORM>
> >
> > </BODY>
> >
> > </HTML>
> >
> >
> >