Handle keypress event correctly for the player