0

jquery:

$('#search').keypress(function(e) {
  if (e.keyCode == 13) {
    $('#search').blur();
  }
});

Html:

<div>
  <input id="search" type="text">
 </div>

I want to detect the enter (or go) key event in jquery when the key is pressed on mobile devices like android, once the key is pressed, i need to blur the input box field.

but my above of jquery code is not working. please help me.

LogaKrishnan
  • 491
  • 1
  • 9
  • 24

1 Answers1

1

Reedit:

$('#search').on('keyup',function(e) { 
if (e.keyCode == 13) { 
$('#search').blur(); 
} 
});
aolphn
  • 2,950
  • 2
  • 21
  • 30