Create separate thread for input and for printing the snake. Temporarily remove the logic to remember the right/left/up/down keys. You need to press them to move by one position.