Reputation: 51
I want to open custom pop up using pressing CTRL+F but in IE it opens find option also. How can I prevent that find option?
Upvotes: 0
Views: 37
Reputation: 1074276
You hook keydown
and prevent the default action:
document.addEventListener("keydown", function(e) {
if (e.ctrlKey && (e.which || e.keyCode) == 70) { // 70 = F key
e.preventDefault();
console.log("You pressed Ctrl+F");
}
}, false);
Click here to focus the document, then press Ctrl+F
This works on IE11 as well as Chrome and Firefox, with Ctrl+F. You can't override some other keys, such as Ctrl+T.
Upvotes: 1