[英]How do I prevent safari from using the command key other than how I specified it in my javascript?
At the moment, my code uses the command key in combination with other keys to call functions within our javascript. 目前,我的代码结合使用Command键和其他键来调用我们JavaScript中的函数。 This functionality currently works within firefox, however in safari by pressing combinations such as command + "+" or command + "1" it does not do the intended functionality and instead does the functionality inherent to the browser.
该功能目前在Firefox中有效,但是在野生动物园中,通过按诸如Command +“ +”或Command +“ 1”之类的组合,它不会执行预期的功能,而是会执行浏览器固有的功能。 I am currently using the preventDefault() function, which is why this works in firefox, but I am not sure what this does not work in safari.
我目前正在使用preventDefault()函数,这就是为什么它在firefox中可以工作的原因,但是我不确定在Safari中它不能工作的原因。 Any ideas?
有任何想法吗?
I have never been able to convince Safari to let me control command 1 through 9, but event.preventDefault() seems to work fine on - and = when binding to keydown. 我一直无法说服Safari让我控制命令1到9,但是当绑定到keydown时,event.preventDefault()在-和=上似乎可以正常工作。 The normal zoom in/out are suppressed as expected.
正常放大/缩小被抑制。
Try this: 尝试这个:
if (event.preventDefault) {
event.preventDefault();
}
if (event.stopPropagation) {
event.stopPropagation();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.