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>
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?
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.
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.