Skip to content Skip to sidebar Skip to footer

Distinguish The Keypress And Click In Mozilla When Nvda Is On

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

Solution 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:

<buttononmousedown="pointerFunction()"onclick="clickFunction()">Active this</button><script>var isPointerEvent = false;
functionpointerFunction() {
    isPointerEvent = true;

    // Do something for pointer users
}

functionclickFunction() {
    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

Post a Comment for "Distinguish The Keypress And Click In Mozilla When Nvda Is On"