Distinguish the keypress and click in Mozilla when NVDA is ON

时光毁灭记忆、已成空白 提交于 2019-12-14 02:38:33

问题


Requirement is to distinguish the keypress and mouse click events in Mozilla browser. The condition is that the Mozilla browser should be able to distinguish the events (click and enter) when the NVDA IS TURNED ON


回答1:


If you're only looking to distinguish between Enter/Space press and mouse/pointer press, I would probably go for using both an onclick and an onmousedown.

If the onmousedown is fired, I would set a flag, that I would read in the onclick, telling me whether this was actually originally a pointer event.

Something like:

<button onmousedown="pointerFunction()" onclick="clickFunction()">Active this</button>

<script>
var isPointerEvent = false;
function pointerFunction() {
    isPointerEvent = true;

    // Do something for pointer users
}

function clickFunction() {
    if (isPointerEvent) {
        return isPointerEvent = false;
    }

    // Do something for keyboard / screen-reader users
}
</script>

For the record, I posted the same suggestion here for a similar question: https://stackoverflow.com/a/57055357/10494842



来源:https://stackoverflow.com/questions/52914854/distinguish-the-keypress-and-click-in-mozilla-when-nvda-is-on

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!