3

I am using Bootstrap.When press enter in textbox ,open Modal popup with Bootstrap.But when I using mobile phone ,I cant detect pressing enter.How to detect it ?Can you help me please? My code ;

<script type="text/javascript">
     $(document).ready(function () {

           $('.form-control').keyup(function (e) {
               if (e.which == 13)   {      
                   $('.modal').modal('show');
               }
           });

       });
    </script>   
Fikret Savaş
  • 127
  • 4
  • 12

2 Answers2

7

Normally, within a form, the enter key on a mobile device submits the form. I suggest adding some logic in a submit handler:

$("#myForm").submit(function(){
      // you're logic here
}

Additional information

See: HTML: Why does Android browser show "Go" instead of "Next" in keyboard?

Community
  • 1
  • 1
James Hill
  • 60,353
  • 20
  • 145
  • 161
  • @GlenSwift, may I suggest some reading? http://stackoverflow.com/questions/6545086/html-why-does-android-browser-show-go-instead-of-next-in-keyboard – James Hill Sep 17 '14 at 08:19
-1

Well, on touch devices there is no such event as keyup as far as I know. At least in iOS: https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html#//apple_ref/doc/uid/TP40006511-SW5

Consider using form's submit event instead.

Cœur
  • 37,241
  • 25
  • 195
  • 267
YuS
  • 2,025
  • 1
  • 15
  • 24