I have a question in react/JavaScript that when I press Tab on the keyboard, I need the Enter key to be triggered or active, so any idea how can I do it.
Although I'm not sure what you're motivation for this behavior is, your logic is even possible with Vanilla JS:
Minimal example for your use case:
tab
enter
was pressed as well (programmatically)let element = document.querySelector('input');
element.onkeydown = e => {
alert('key pressed: ' + e.key);
if (e.key === 'Tab') {
element.dispatchEvent(
new KeyboardEvent('keydown', {
'key': 'enter'
}));
}
}
<input/>