title: I'm having a bit of trouble when it comes to "while" statements in Java
body: <p>This is a Java problem. I'm having a bit of trouble operating a while loop inside this "if" statement hanging around in the KeyListener. It is a bit frustrating trying to loop my rectX -= snakeSpeedY.</p>
  
  <pre><code>public void keyPressed(KeyEvent e) {
      if (e.getKeyCode() == KeyEvent.VK_UP){
          AUTO = false; //boolean for automatic movement FYI.
          while (snakeMoving == true) {//another boolean, for stoping and moving the snake
              rectY -= snakeSpeedY;
          }
  </code></pre>
  
  <p>I'm wondering if the "if" statements can't handle while-loops? Am I doing it wrong? All feedback would be appreciated.</p>
  
  <p>EDIT: I focused mainly on this proportion of my code because this was where the problem happened. I'm sorry for not including the "If" brackets.</p>