Updated KeyPressed and KeyReleased method