Ashish
Ashish

Reputation: 51

how can I prevent opening the default option in IE?

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

Answers (1)

T.J. Crowder
T.J. Crowder

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

Related Questions