Making touch events accessible

Applies to Windows and Windows Phone

For technical reasons, HTML touch events such as pointerUp aren't programmatically accessible by default. To make them accessible, and to allow Narrator touch gestures to activate your app's functionality, add code to hook touch events to the click event, which is programmatically accessible by default.


element.addEventListener("click", onClick);
element.addEventListener("PointerUp", onPointerUp);

...

var pointerUpEventObject = null;
var pressedElement = null;
var isUiaClick = false;

function onClick(evt) {
    isUiaClick = true;
    delayedPointerUp();
}

function onPointerUp(evt) {
    pointerUpEventObject = evt;
    setImmediate(delayedPointerUp);
}

...

function delayedPointerUp() {
    if (isUiaClick || pointerUpEventObject && 
            (pointerUpEventObject.srcElement == pressedElement || 
            ...right button checks...)) {
        pointerUpEventObject = null;
        isUiaClick = false;
        invokeItem(pressedElement);
    }
}

...

 

 

Show:
© 2014 Microsoft