OnKeyPress workaround for IE Mobile

I am coding a very simple page that uses onkeypress to alter a formfield and then submit the form on the page. I would like to be able to use this page from my mobile device but I found info that tells me that IE Mobile doesnt support any Event captures.

Is there a workaround for this that utilises IE Mobile capabilities to the same end result?

Thx
robertybobAsked:
Who is Participating?
 
robertybobConnect With a Mentor Author Commented:
sry - forgot about this question - there seems no workaround for this error and i'm investigating other mobile units
0
 
Michel PlungjanIT ExpertCommented:
onkeypress of what?
how do you capture?

Do you have
<input type="text" onKeyPress="something(this)">

or is it
document.onkeypress=something;
0
 
robertybobAuthor Commented:
hi mplungjan - the code uses something like this to insert a word into the formfield. Works in normal IE, doesnt seem to work in FF but no probs at the moment.....main thing is to get it to work on IE Mobile

function keyHandler(e){
    var pressedKey;
    var selection;
    if (document.all)    { e = window.event; }
    if (document.layers) { pressedKey = e.which; }
    if (document.all)    { pressedKey = e.keyCode; }
    pressedCharacter = String.fromCharCode(pressedKey);
    if(pressedKey=='97') { selection = 'Apple'; }
    if(pressedKey=='98') { selection = 'Banana'; }
    if(pressedKey=='99') { selection = 'Cherry'; }
    document.boxform.word.value = selection;
}
document.onkeypress = keyHandler;

hope this helps :)
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Michel PlungjanIT ExpertCommented:
For FF/NS/Mozilla and IE:


function keyHandler(e){
    var pressedKey = (e) ? e.which : window.event.keyCode;
    var pressedCharacter = String.fromCharCode(pressedKey);
    if(pressedKey=='97') { selection = 'Apple'; }
    if(pressedKey=='98') { selection = 'Banana'; }
    if(pressedKey=='99') { selection = 'Cherry'; }
    document.boxform.word.value = selection;
}
document.onkeypress = keyHandler;

Can you perhaps do

var fruit = { a: "Apple", b: "Banana", c: "Cherry"}

<input type="text" onKeyUp="if (fruit[this.value]) this.value=fruit[this.value]">

0
 
robertybobAuthor Commented:
the onKeyUp version doesnt trigger either :(

dont think IE Mobile allows any onkeydown, onkeyup, onkeypress, onmousemove, onmousedown and onmouseup events - not sure if there's a coding way round this or if MS have some kind of add-on package to boost the mobile IE functionality
0
 
robertybobAuthor Commented:
Of course I'm only suggesting IE Mobile cos its on the device - if anyone can categorically confirm that these events are handled by another mobile browser which can also handle things like Ajax and all other IE capabilities then thats fine - I can try that if its free of charge.

Thx

0
 
Michel PlungjanIT ExpertCommented:
I am frankly very surprised... I have a Nokia n80 and its browser can handle almost all javascript...
0
 
robertybobAuthor Commented:
Yup me too :) I have word that IE5 couldnt support this but IE6 can so i'm trying to investigate the software on the clients device tmrw. Tho its brand new and the spec says IE6 Mobile - will check with my own eyes on Monday and post here the conclusions.
0
 
robertybobAuthor Commented:
ok - it seems to be version 6.12 but definitely not allowing onkeypress :(
0
 
Michel PlungjanIT ExpertCommented:
Super strange...

If you wish, ask for a PAQ and refund
0
 
robertybobAuthor Commented:
lol :) i've just noticed that the OS is WInCE not Win Mobile so just investigating if this makes any difference
0
 
Michel PlungjanIT ExpertCommented:
Great
0
 
dsackerContract ERP Admin/ConsultantCommented:
Robertybob, you still around? This is still a problem with Windows Mobile, but there is a dirty workaround, if you're still interested. Post another question (and give me a heads up). :)
0
All Courses

From novice to tech pro — start learning today.