0

Map enter key to tab key

i want to focus on next html element on enter key same as that of tab.
i tried following code but its not working.
i don't want to write any code i just want to map enter key to tab.

 dockeyUp(e) {
    if (e.keyCode == 13) {
      e.keyCode = 9;
      e.preventDefault();
    }
  }

  componentWillMount() {
    document.addEventListener("keyup", this.doc_keyUp, false);
  }

on above code i get error that keycode is readonly property

Community
  • 1
  • 1
ketan kulkarni
  • 355
  • 1
  • 4
  • 11
  • Possible duplicate of [Firing a Keyboard Event in JavaScript](https://stackoverflow.com/questions/961532/firing-a-keyboard-event-in-javascript) – Dom Aug 30 '18 at 09:20
  • do you need to focus on next element while enter check this code once, https://stackblitz.com/edit/react-tcgeqb – Jayavel Aug 30 '18 at 10:11

0 Answers0