mercredi 27 février 2019

How can detect tab key in onclick method in html?

I have a select in HTML:

<select name="departamento" id="departamento" onclick="console.log('1')">
  <option>1</option>
  <option>2</option>
  <option>3</option>
</select>

When a user presses the Tab key when the cursor is on an option the output in the console is 1.

I don't want that. I want to prevent the execution of onclick when user presses the Tab key. The solution can be in jQuery or Javascript.




Aucun commentaire:

Enregistrer un commentaire