JAWS / IE11 中的按键事件未正确触发

Keydown Event in JAWS / IE11 not firing properly

我们正在努力解决我们的视频播放器的一些辅助功能问题,其中之一是使用键盘在视频中滚动的能力。我们有以下代码,它在 keydown 时暂停视频并擦除视频 forward/backward,然后在 keyup 时它在新点播放视频。

问题是在带有 JAWS 的 IE11 中,keydown 事件不会在按住键时持续触发。它在 keydown 和 keyup 之间来回切换。结果就是无限循环向前移动一秒然后回到视频中的原点播放。

这是我们目前正在使用的代码,我们可以做些什么来让它与 JAWS 一起工作?

document.addEventListener("keydown", function(ev) {
      if (ev.keyCode === 37 || ev.keyCode === 39) {
        console.log("keydown");
      }
    });

document.addEventListener("keyup", function(ev) {
      if (ev.keyCode === 37 || ev.keyCode === 39) {
      console.log("keyup");
    });

很高兴添加您可能需要的任何其他信息或回答任何问题,请告诉我

您遇到的问题与 JAW 如何拦截按键和使用虚拟光标有关。

当按下左右键时,它试图说出上一个和下一个字符,因此它拦截按键,执行操作并将向左箭头键传递给浏览器一次,就像在 'document browsing mode' 中一样.

停止此行为的一种方法是使用 role="application",这会指示屏幕阅读器正常将所有信息传递给浏览器。

显然,您需要阅读 role="application" 上的所有文档,因为如果您不小心,可能会引入可访问性问题而不是修复它们!

相关 W3 指南

W3 Role - application information

When the user navigates an element assigned the role of application, assistive technologies that typically intercept standard keyboard events SHOULD switch to an application browsing mode, and pass keyboard events through to the web application. The intent is to hint to certain assistive technologies to switch from normal browsing mode into a mode more appropriate for interacting with a web application; some user agents have a browse navigation mode where keys, such as up and down arrows, are used to browse the document, and this native behavior prevents the use of these keys by a web application.