[英]How to prevent Firefox' in-site-search from popping up?
My problem is, is that the numpad's "/" key triggers the search bar in Firefox.我的问题是,小键盘的“/”键会触发 Firefox 中的搜索栏。 I would like to prevent this from happening.我想防止这种情况发生。
I'm currently working on an online Calculator, and ran into the problem described earlier.我目前正在开发一个在线计算器,并遇到了前面描述的问题。 The reason why I would like this not to happen, is because you obviousely can't type in a division thanks to this feature.我不希望这种情况发生的原因是,由于此功能,您显然无法输入除法。 The page is only meant to run in Firefox, and it's just a little help for my little brother, so it doesnÄt have to be the most professional solution - if it works, it's fine.该页面仅用于在Firefox中运行,对我的小兄弟有一点帮助,所以它不一定是最专业的解决方案——如果它可以工作,那就没问题了。 I've already tried the preventDefault method, but that doesn't change anything.我已经尝试过 preventDefault 方法,但这并没有改变任何东西。
Any help is appreciated!任何帮助表示赞赏!
(Sorry if this question was already asked before, or it doesn't append to the rules, I'm totally new to StackOverflow) (对不起,如果这个问题之前已经被问过,或者它不符合规则,我对 StackOverflow 完全陌生)
window.addEventListener("keyup", function (event) {
let signs = ["*", "-", "/", "+"];
event.key.preventDefault;
if (!(isNaN(event.key)) || signs.includes(event.key)) output.value += event.key;
else if (event.keyCode === 8) {
output.value = output.value.slice(0, -1);
}
})
//This is a snippet of my code right now, but the event.key.preventDefault part doesn't work for my problem
I think you should use preventDefault like this:我认为你应该像这样使用 preventDefault :
event.preventDefault();
I don't know whether this will block the search box or not, but you can call preventDefault like this.我不知道这是否会阻止搜索框,但是您可以像这样调用 preventDefault 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.