KeyboardEvent.srcElement
is now deprecated (according to my IntelliJ) and TypeScript now uses KeyboardEvent.target
.
My question is: With .target
, how do you access the .nextElementSibling
field that .srcElement
used to have? I am trying to implement the code below to focus on the next input field of an HTML form when the Enter key is pressed.
keytab(event){
let element = event.srcElement.nextElementSibling; // get the sibling element
if(element == null) // check if its null
return;
else
element.focus(); // focus if not null
}```