简体   繁体   English

如何让屏幕阅读器 NVDA 在 listitem (ARIA) 上按下 ENTER 键?

[英]How can I make screen reader NVDA reads ENTER key when press it on listitem (ARIA)?

I'm trying since yesterday to make it work, but i can't.我从昨天开始就在努力让它工作,但我做不到。 The problem is: I have a list of items that you can tab and select one of them with ENTER key, but the ScreenReader doesn't read anything when you press ENTER key to the selected item.问题是:我有一个可以选项卡的项目列表,select 其中一个带有 ENTER 键,但是当您按 ENTER 键进入所选项目时,ScreenReader 不会读取任何内容。

I tried many things, aria-selected="false" (which only works with buttons, but i'm trying to do this with an <a> , so it doesn't work), javascript, aria-atomic="true" but enter key doesn't reads in nvda(screenreader)我尝试了很多东西, aria-selected="false" (它只适用于按钮,但我试图用<a>来做到这一点,所以它不起作用),javascript,aria-atomic="true"但输入键不读取 nvda(屏幕阅读器)

This is the piece of code that i'm trying to fix这是我要修复的一段代码

<div class="SelectedNames"> <ol> <li ng-repeat="name in names" ng-class"isSingleNameSelected(name) == true? 'selected': no-selected'" ng-click="verifySelected(name)"> <a href="%" class="nameTitle> {{ item.name }}</a>

I'm modifying inside of the part.我正在修改零件内部。 Because i guess that it can work without touching the rest of the code因为我猜它可以在不触及代码的 rest 的情况下工作

I don't mind if you can show me another way like javascript without aria to do this.我不介意您是否可以向我展示另一种方式,例如没有 aria 的 javascript 来执行此操作。 I only need it to works when you press enter to an item in the listitem I will apreciate if someone can discover how to fix it, because i can't.我只需要它在您按 Enter 进入列表项中的某个项目时才能工作,如果有人能发现如何修复它,我会很感激,因为我做不到。 Thank you谢谢

Your question is not very clear.你的问题不是很清楚。 But I understand you want the 'click' functionality to work on hitting the 'enter' button too.但我了解您希望“点击”功能也可以在点击“输入”按钮时发挥作用。 If my understanding is correct, you need to add the (keypress) event.如果我的理解是正确的,则需要添加(keypress)事件。

Seems like you are using Angular (since i can see ng-repeat and all).好像您正在使用 Angular (因为我可以看到 ng-repeat 和所有)。 So your code can change to this to support Keyboard accessible.因此,您的代码可以更改为此以支持键盘可访问。

This is called Keyboard accessibility:这称为键盘可访问性:

// Only Mouse click event 

<li (click)="callSomeFunction($event)"> 
   Some LI item
</li>


// Mouse click and Keyboard accessible event
<li (click)="callSomeFunction($event)" (keypress)="callSomeFunction($event)"> 
   Some LI item
</li>

What (keypress) will do is, whenever you press any button on the keyboard, it will call that function. (keypress)会做的是,每当你按下键盘上的任何按钮时,它都会调用 function。

There are 2 more events which you can use: (keyup) and (keydown) which will let you control the calling of the function after the pressing of the key is done or during the pressing of the key.您可以使用另外 2 个事件: (keyup)(keydown) ,您可以在按键完成后或按键期间控制 function 的调用。 You may use whatever you want to achieve the above functionality.您可以使用任何您想要实现上述功能的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM