Windows 10 上的 Firefox 不会检测与另一个Alt键keydown
一起使用的键,但会检测到该Shift键。Chrome 和 Edge 按预期检测两者。
在 Firefox 中,以下代码段显示event.shiftKey
已正确检测到,但event.altKey
从未检测到。在 Chrome 和 Edge 中,event.altKey
可以正确检测到。(在 Chrome 和 Edge 中按下Alt或Shift触发keydown
,但在 Firefox 中没有,这就是为什么我说“与另一个键一起使用。”)
<!doctype html>
<html>
<head></head>
<body></body>
<script>
document.addEventListener("keydown", function(event) {
console.log("Alt: " + event.altKey);
console.log("Shift: " + event.shiftKey);
}, false);
</script>
</html>
2019 年的一个问题在 Firefox 69 中报告了同样的问题,但解决方案显然是在 Firefox 中,&&
当用于检测多个键Alt是否被按下时会破坏某些东西。
2012 年的一个问题在 Chrome 中报告了同样的问题,答案是Alt在 Chrome 中按下会启用窗口菜单,因此页面失去焦点并且keypress
不会调用事件。在 Firefox 中可能会发生类似的事情,因为如果在 Firefox 中启用了菜单栏,按下会Alt打开菜单栏的第一项(文件)。但是,该问题的答案表明“keydown”确实有效。
我在 Windows 10 上使用 Firefox 93.0。我尝试在故障排除模式下打开 Firefox(因为我已经对 Firefox 进行了广泛配置),但问题仍然存在。
任何帮助,将不胜感激!
编辑:这似乎是由privacy.resistFingerprinting
in引起的about:config
。