title: click for select and deselect of single drop down like multiple in bootstrap-select
body: <p>I have used bootstrap select </p>
  
  <p>Now, when I click on an option it should be selected as it is working fine, but when I click on the same option it should be deselected with both <code>click</code> and <code>Enter</code> keypress event how it is working on multiple select I just want the same way for single select.</p>
  
  <p>I have tried the following code to select and deselect on click event it's working fine but when I am trying to do it with the keyboard <code>enter key</code> it's not even getting selected.</p>
  
  <p>Any help appreciated :-)</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$('.selectpicker').selectpicker({
      liveSearch:true,
      showTick:true
  });
  
  $(document).on('click', '.dropdown-menu li', function(event){ 
      if($(this).hasClass('active')){
   $(this).parent().prev('div').parent().next('select').selectpicker('val',''); } 
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"&gt;&lt;/script&gt;
  &lt;link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/&gt;
  
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/js/bootstrap-select.min.js"&gt;&lt;/script&gt;
  &lt;link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.12.4/css/bootstrap-select.min.css" rel="stylesheet"/&gt;
  
  &lt;select class="selectpicker"&gt;
      &lt;option&gt;Mustard&lt;/option&gt;
      &lt;option&gt;Ketchup&lt;/option&gt;
      &lt;option&gt;Relish&lt;/option&gt;
  &lt;/select&gt;</code></pre>
  </div>
  </div>
  </p>