简体   繁体   中英

How to detect text enters in the CTR+F input box

How we can find text enters in the CTR+F input box with the core javascript?

In this screenshot, I have searched Of course text.

How we can find Of course text?

在此处输入图片说明

In general, you cannot invoke browser controls from inside the webpage - security, sandboxing, and all that. A trick could be listening to Ctrl + F , prevent it and then capture all the keys user enters then do what you want to do .

window.addEventListener("keydown",function (e) {
    if (e.keyCode === 114 || (e.ctrlKey && e.keyCode === 70)) { 
        callBackCtrlF();
        e.preventDefault();
    }
})

then you could use :

function callBackCtrlF() {
     // do your stuff
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM