Fixed bug in keyPressed()