Fix keyPressed logic