简体   繁体   中英

How to detect JavaScript key events in Windows Mobile 5 browser?

I have a text box on a webpage which upon pressing the enter key, it should do something. So I detect the key code for the Enter key onkeyup.

My issue is, it appears that any JavaScript key events (keypress, keydown, keyup) do not work in the Windows Mobile 5 IE browser? I've tried onlblur as well. I'm looking for a JavaScript solution ideally.

I've seen some suggestions on the web about setting KeyPreview to true, but that appears to be only for Windows Forms.

HTML example (seems to work fine in situations other than this):

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
    function isEnterPressed(){
        if (window.event.keyCode == 13) {
                alert("Enter was pressed!");
            }
        }

</script>
</head>
<body onload="document.getElementById('txtEntry').focus();">
    <span>
        Press the enter key...if enter is detected, message will display below.
    </span>
    <br />
    <input type="text" id="txtEntry" onkeyup="isEnterPressed()">
</body>
</html>

If this is really Windows Mobile 5 there is no way to get JavaScript events for key presses as JScript in Windows Mobile 5 does simple NOT support any key event. Javascript Key event support started with Windows Mobile 6 (AKU 6.1.4 or so).

There are third party 'browser' like Intermec Browser, NaurTecc and zetakey that either support javascript key events or provide a workaround using special META tags or setup that is captured by the browser 'wrapper'.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM