how to select row with keyup and keydown in grid element

I look a way to autoselect row with keyup and keydown (without press enter) in the grid element;
It would be convenient for me have an even like “focues-items-changed” just like selected-items-changed.

For now the only solution i have found is uncomfortable…

Is there a way to know when row get focus ?
Thanks in advance
p.s.
This is temporary solution that I found. Is there a better way to implement it ?

//grid is vaadin-grid polymer element 
grid.addEventListener('keyup', function(e) {
    var i=grid.selection.selected()[0]
;
    if (i===undefined) {
        grid.selection.select(0);
        return;    
    }
    if (e.code=="ArrowDown") {
        if (i==grid.items.length) return;
        i++;
        grid.selection.select(i);
    }
    if (e.code=="ArrowUp") {
        if (i==0) return;
        i--;
        grid.selection.select(i);
    }
    
    //TODO: handle PageUP and PageDown

});


Is there a way to know when the focus of a line change?