Skip to content

Submit Search Only On Enter Key? #2015

Jul 12, 2021 · 4 comments · 8 replies
Discussion options

You must be logged in to vote

Here is how my code looks and it works perfect. Thank you for unofficial setting "automatic: false".

<div class="ui category search">
  <div class="ui transparent icon input">
    <input id="search" class="prompt" type="text" >
    <i class="search link icon"></i>
  </div>
  <div class="results"></div>
</div>
// fixes "backspace" key issue.
$('#search').on('keyup',function(){
  if ($.trim($(this).val()).length == 0) {
    $('#search').blur(); // hide results
    $('#search').focus().select(); // focus input
  }
});

// fixes "enter" (submit) key issue.
$('.ui.search').on('keyup', function(e) {
  if (e.keyCode == 13) {
    $('#search').focus().select();
  }
});

// search javascript
$('.ui…

Replies: 4 comments 8 replies

Comment options

You must be logged in to vote
2 replies
@ghost
Comment options

@lubber-de
Comment options

Comment options

You must be logged in to vote
1 reply
@lubber-de
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
5 replies
@lubber-de
Comment options

@ghost
Comment options

@ghost
Comment options

@lubber-de
Comment options

@ghost
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment