I am using WordPress jQuery to build some shortcuts for my site.
It works as intended, however it doesn't stop when other keys are pressed.
For example, if I press, f
it performs the necessary task. But if I press CTRL + f
then also it does the task.
Infact, I tried, other keys like f
and p
and that too worked.
I want it to only work on the specific key. Incase of any other key press, it should not run. It should run on clicking f, but NOT run on CTRL + f.
I tested this on Chrome 92.0.4515.159 and Chrome Beta Version 94.0.4606.31 on Windows 7 and 8.
jQuery(window).keydown(function(e) {
if( e.which === 27){
jQuery('.SearchCreationsClose').click();
}
if(e.key == "f"){
e.preventDefault();
jQuery('.SearchCreationsIcon').click();
}
});