Thanks everyone, I figured it out. The code works fine with arrow keys and not the Tab key. My problem is solved