1

I got multi-select HTML input, I want to single select on Ctrl + left mouse button click or disable Ctrl-click functionality. How do i achieve this?

http://jsfiddle.net/dct1x25v/3/

<select multiple="" id="MySelect">
  <option>I am Option 1</option>
  <option>I am Option 2</option>
  <option>I am Option 3</option>
  <option>I am Option 4</option>
  <option>I am Option 5</option>
  <option>I am Option 6</option>
  <option>I am Option 7</option>
  <option>I am Option 8</option>
  <option>I am Option 9</option>
</select>

Already tried:

$('#MySelect').bind("mousedown", function (e) {
  // alert(event.keycode)
  e.metaKey = false;
}).selectable()

$(#MySelect).keydown(function(event){
  if(event.which=="17")
    cntrlIsPressed = true;
  alert(event.which)
});

Didn't work.

1
  • the selector should have quotes around it ... Commented Dec 18, 2018 at 12:15

1 Answer 1

3

try this disable ctrl + click;

$('#MySelect').mousedown(function(e)
{  
    if(e.ctrlKey){
        return false;
    }  
}); 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.