I'm trying to loop focus in a dropdown in my webpage while using screen reader in mobile. In dev tools mobile view, I am able to achieve the same. But as soon as I open screen reader in actual device (S10+ or iPhone X), the forward swipe gesture doesn't fire any event. I went on researching and found that browse mode doesn't actually provide focus to any element and just reads it unless tapped.
So, is there any way/method by which we can identify which element is currently active in scree reader browse mode. Or we just can not do it.
function trapFocus(firstElem, lastElem) {
// shift+tab on first element
$(firstElem).on('keydown', function(e) {
if (e.shiftKey && e.keyCode == 9) {
$(lastElem).focus();
e.preventDefault();
}
});
// tab on last element with no shift
$(lastElem).on('keydown', function(e) {
if (!e.shiftKey && e.keyCode == 9) {
$(firstElem).focus();
e.preventDefault();
}
});
}