Javascript keyevent和JAWS屏幕阅读器 [英] Javascript keyevent and JAWS screen reader

查看:197
本文介绍了Javascript keyevent和JAWS屏幕阅读器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,每次按下空格键时都会执行某些操作(例如警报)。如果我不使用JAWS屏幕阅读器,这可以正常工作。但是,一旦我加载JAWS屏幕阅读器,当我按空格键时它不会执行警报。我需要使用JAWS,所以我需要这个工作。这是代码片段。

I have an application that does something (eg alert) each time a spacebar is pressed. This works fine if I am not using JAWS screen reader. However, once I load JAWS screen reader, it does not execute alert when I press the spacebar. I need to use JAWS so I need this to work. Here is the code snippet.

$(document).keypress(function(event) {
    var chCode = ('charCode' in event) ? event.charCode : event.keyCode;
    if (chCode == 32){ //32 is keyCode for spacebar
      alert("spacebars!!!");
    }
});

根据我的观察,似乎JAWS抓住键盘焦点并且不允许空格键事件触发。当我按下空格键时JAWS总是读取Space但警报事件不会触发。当空格键按下时,如何仍然可以触发警报或doSomething()?如何从JAWS获取控制权或者可以与JAWS共享键盘控制,这样即使JAWS读出我按下的角色(在本例中为Spacebar),它也会允许我的事件(警报)触发。谢谢。

From my observation, it seems JAWS grabs the keyboard focus and wouldn't allow the spacebar event to fire. JAWS always reads "Space" when I press the spacebar but the alert event does not fire. How can I still get the alert or doSomething() to fire when the spacebar is pressed? How can I take control from JAWS or maybe share keyboard control with JAWS such that even though JAWS reads out the character I pressed (in this case Spacebar), it will allow my event (alert) to fire. Thanks.

更多代码:

$(document).keypress(function(event) {
  var cc= ('charCode' in event) ? event.charCode : event.keyCode;       
       if (cc == 32)
    {
      spArray.push(Number(new Date()));
    }
});


推荐答案

一般情况下,不建议覆盖屏幕读者,即使他们让你。有很多 JAWs键盘命令(与INS一起)使用空格键,您可能会锁定这些命令。

In general it is not advisable to over-ride screen readers, even if they let you. There are quite a few JAWs keyboard commands (in conjunction with INS) that use the spacebar, and you'd probably lock those commands out.

如果该区域主要是表单控件或交互式小部件,那么您可以将其包装在 role =application 。这使得(窗口)屏幕阅读器进入表单模式,其中键被传递到网页。

If the area is primarily form controls or interactive widgets then you could wrap it in an element with role="application". That puts a (windows) screen reader into 'forms' mode, where keys are passed through to the web-page.

将所有内容包装在 role =application中,只是交互区域。

Do not wrap everything in role="application", just the interactive area.

更新:有了更多信息,这是关于用户触发音频文件的基于音频的捕获,然后再触发一些内容设置时间并传递捕获。

Update: With more information, this is about an audio-based capture where the user triggers an audio file, then triggers something again to set a time and pass the capture.

使用原生按钮,Jaws将通过使用enter(不确定空间,这不是通常的激活键。我建议检查输入密钥(我认为是charcode 13),甚至 onclick 应该可以工作。在原生按钮/链接上,它适用于屏幕阅读器。

Using a native button, Jaws will pass through the use of enter (not sure about space, that isn't the usual 'activate' key). I'd suggest either checking for enter key (charcode 13 I think), or even onclick should work. On a native button/link it works across screen readers.

$(document).click(function() {
   spArray.push(Number(new Date()));
});

假设它位于正确的位置,以便在需要之前不会变为活动状态。 (JS不是我的强项,但请使用回车键或 onclick

Assuming that's in the right location so that it doesn't become active until needed. (JS isn't my strong point, but go with the enter key or onclick.

这篇关于Javascript keyevent和JAWS屏幕阅读器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆