added TabKey and fixed the initial condition to enter for loop