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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

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
robertybobAuthor Commented:
sry - forgot about this question - there seems no workaround for this error and i'm investigating other mobile units
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Smartphone Programming

From novice to tech pro — start learning today.