I want to detect the Control + A event in input. I can find the Control + A event, but the function is continuing even after return false
.
jsFiddle - http://jsfiddle.net/f6rcgpmh/4/
$('.searchTerm').keyup(function(e) {
$(#status).text();
if (e.ctrlKey) {
if (e.keyCode == 65 || e.keyCode == 97) { // 'A' or 'a'
console.log(Control pressed);
e.preventDefault();
return false;
}
}
$(#status).text(This should not work if Ctrl + A is pressed);
});
<script src=https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js></script>
<form id=search class=search>
<input class=searchTerm placeholder=Filter Books...>
<input class=searchButton type=submit>
</form>
<div id=status></div>
I want this to work in keyup
not in keydown
. Because I am using autosearch and I don't want to call function before keyrelease. And also Ctrl + A won't highlight text in keydown when it returned false.