Fix a bug on keyPressed()