onTab function determines tab next behaviour