Disable press tab button to next input field in web form

For example below, user can press tab button on the keyboard to go to next field. Can I disable this function?

<form action="/action_page.php">
  First name:<br>
  <input type="text" name="firstname">
  Last name:<br>
  <input type="text" name="lastname">
      <select name="gender">
        <option value="M">M</option>
        <option value="F">F</option>
  <input type="submit" value="Submit">

Answers 1

  • Yes use keydown like this :

    document.querySelector('input').addEventListener('keydown', function (e) {
        if (e.which == 9) {

Related Articles