Detect Ctrl + A in keyup event

Actually the function stops. What you are experiencing is that two keyup events trigger: the one from ctrl and the one from A.

The first one returns as expected because it does fill the requirements: ctrlKey == true and keyCode == 65 || keyCode == 97.

But the second one, there will be only one key pressed so both statements can't be true together:

  • If you last released the ctrl, then ctrlKey is true but keyCode == 65 || keyCode == 97 is not.

  • If you last released the A, then ctrlKey is now false.

Then the line which sets #status to an error message is run.


Actually it's not. You must change your event from 'keyup' to 'keydown'. Then try it again. You can check this fiddle. http://jsfiddle.net/ebilgin/f6rcgpmh/5/


If you need control on autocomplete, you have to put your controls before sending the data.

The Ctrl keyup event trigger causes your problem. I added another condition to your code,

if (e.keyCode == 17) // Ctrl key, fires at Ctrl's keyup.
    return false;

You can check my new fiddle, http://jsfiddle.net/ebilgin/f6rcgpmh/10/.