I tried making a pointer to first li and then tried navigating through it but not working in my case: [this is the pic of my dom element ][1]
[1]: https://i.stack.imgur.com/f1uO6.png
Code:
$(window).keyup(function(e) {
console.log("Key Code: ", e.keyCode);
var $currentParent = $('div[data-tree-model] li.active');
console.log("Current Parent", $currentParent);
var $next;
if (e.keyCode === 39 || e.keyCode === 37) {
$currentParent[0].firstElementChild.click();
} else if (e.keyCode == 38) {
$next = $currentParent.prev();
} else if (e.keyCode == 40) {
$next = $currentParent.next();
}
if ($next.length > 0) {
$('div[data-tree-model] li ').removeClass('active');
$next.addClass('active');
}
});