How to get if a player presses the TAB key in a forum

By : tim pim

So, I'm making a school project (a game of some sorts), and we all get a mail address from school. Now I record the mail address in a database and want to add a little feature. If the 'player' presses the tab key in the third forum box, the fourth gets automatically filled with the number they entered in the third box (student number) with @... after it.

How can I fire an event when the tab key is pressed in the third box? I now have:

      function autoMail() {
        if (event.keyCode == 9) {
          console.log("Mail is automatisch ingevuld!");

<td style="color: white; font-weight: bold;" onkeypress="autoMail()">Leerlingnummer:</td>

This doesn't work, however. So anyone has an Idea?

(BTW: I already have the onkeypress event somewhere else in the site, wich does work. But I can't figure out why this one doesn't...)

By : tim pim


First of all you need to pass the event to function like this

By : AitorFDK

This video can help you solving your question :)
By: admin