Press the Enter key is called the Back button.. RRS feed

  • Question

  • Hi, all.

    Press the Enter key is called the Back button.

    I want to press the Enter key to invoke the "btnSearch" button.

    Please help me.

    <div class="fragment homepage">
            <header aria-label="Header content" role="banner">
                <button class="win-backbutton" aria-label="Back"></button>
                <h1 class="titlearea win-type-ellipsis">
                    <span id="cityName" class="pagetitle">城市管理</span>
            <div class="content" aria-label="Main Content" role="main">
                <div id="search" style="width: 100%; text-align: center; margin: 0px 0px 50px 0px;">
                    <input id="txtSearch" type="text" required="required" placeholder="输入城市名称" style="width: 300px;
                        height: 30px;" />
                    <button id="btnSearch" style="height: 33px;">添加城市</button>
                <div id="list" style="height: 100%;">
                    <div id="cityListView" data-win-control="WinJS.UI.ListView"></div>

    Monday, July 23, 2012 3:36 PM


  • Hi Xiao.Hu

    You can add this to trigger the onkeypress event.

    txtSearch.addEventListener("keypress", function (e) {
                    // look for window.event in case event isn't passed in
                    if (typeof e == 'undefined' && window.event) { e = window.event; }
                    if (e.keyCode == 13) {
                }, false);
    Best regards
    Tuesday, July 24, 2012 9:06 AM