I have a HTML List with radio buttons as bullet points. Inside the first list element there is a text Input. The focus is on the Text input.
If I TAB to the next element, even if I set tabindexes it skips the <li> and focuses the next elements after the </ul>.
If I press Shift TAB the focus goes to the previouse <li> element. (Actually I think this is good behavior.)
But I have this one customer who can't press shift+TAB.
Is there a way to manipulate / simulate a key press that it is triggered as Shift keypress?
Is there maybe a pure HTML solution?
<ul>
<li><input type='radio'><input type='text'>this input field has focus</li>
<li><input type='radio'>...</li>
</ul>
I tried some Javascript and JQuery trickery but no luck.
$(document).keydown(function (e) {
if (e.keyCode == 9)
{
e.preventDefault();
e = jQuery.Event('keypress');
e.which = 9;
e.shiftKey = true;
$('input').trigger(e);
}
});
Does not work in my case. As well as:
var evt = document.createEvent('KeyboardEvent');
evt.initKeyEvent('keypress',true, true, window, false, false,false, true, 0, e.keyCode 9);
this.dispatchEvent(evt);
question from:
https://stackoverflow.com/questions/66061844/if-tab-is-pressed-can-it-be-triggered-as-shift-tab-jquery-js 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…