title: Problems with KeyListener and JOGL
body: <p>I'm trying to bind a key to translate a GL_QUAD around the screen.  I created a class, as I will attach below, that implements KeyListener, and within that I have a method that upon the keypress of 'd', adds 0.1 to the x coordinates of the quad vertices.  Now, I have two questions relating to this.</p>
  
  <ol>
  <li><p>Firstly, it doesn't seem to do anything.  Upon the keypress, nothing happens to the object.</p></li>
  <li><p>Is there a better way to achieve what I am trying to do?  My end goal is to eventually end up with a sprite, that the camera is focused upon, that can move around a visually 2D game world.</p></li>
  </ol>
  
  <p>Thanks for your time.</p>
  
  <p>Code:</p>
  
  <p>SpriteTest.java</p>
  
  <pre><code>package com.mangostudios.spritetest;
  
  import java.awt.Frame;
  import java.awt.event.WindowAdapter;
  import java.awt.event.WindowEvent;
  
  import javax.media.opengl.GLCapabilities;
  import javax.media.opengl.GLProfile;
  import javax.media.opengl.awt.GLCanvas;
  
  import com.jogamp.opengl.util.FPSAnimator;
  
  public class SpriteTest 
  {
  
  
      public static void main(String[] args) {
          GLProfile glp = GLProfile.getDefault();
          GLCapabilities caps = new GLCapabilities(glp);
          GLCanvas canvas = new GLCanvas(caps);
  
          Frame frame = new Frame("AWT Window Test");
          frame.setSize(300, 300);
          frame.add(canvas);
          frame.setVisible(true);
  
          frame.addWindowListener(new WindowAdapter() {
              public void windowClosing(WindowEvent e) {
                  System.exit(0);
              }
          });
  
          canvas.addGLEventListener(new Renderer());
  
          FPSAnimator animator = new FPSAnimator(canvas, 60);
          //animator.add(canvas);
          animator.start();
      }
  }
  </code></pre>
  
  <p>Renderer.java</p>
  
  <pre><code>package com.mangostudios.spritetest;
  
  import javax.media.opengl.GL2;
  import javax.media.opengl.GLAutoDrawable;
  import javax.media.opengl.GLEventListener;
  
  public class Renderer implements GLEventListener {
      InputListener input = new InputListener();
  
      @Override
      public void display(GLAutoDrawable drawable) {
          update();
          render(drawable);
      }
  
      @Override
      public void dispose(GLAutoDrawable drawable) {
      }
  
      @Override
      public void init(GLAutoDrawable drawable) {
      }
  
      @Override
      public void reshape(GLAutoDrawable drawable, int x, int y, int w, int h) {
      }
  
      private void update() {
      }
  
      private void render(GLAutoDrawable drawable) {
          GL2 gl = drawable.getGL().getGL2();
  
          // draw a triangle filling the window
          gl.glBegin(GL2.GL_QUADS);
          gl.glVertex2f( input.xTran, 0.1f);
          gl.glVertex2f( input.xTran,-0.1f); 
          gl.glVertex2f( -input.xTran, -0.1f);
          gl.glVertex2f( -input.xTran, 0.1f);
          gl.glEnd();
      }
  }
  </code></pre>
  
  <p>InputListener.java</p>
  
  <pre><code>package com.mangostudios.spritetest;
  
  import com.jogamp.newt.event.KeyEvent;
  import com.jogamp.newt.event.KeyListener;
  
  public class InputListener implements KeyListener{
      boolean loopBool = false;
      float xTran = 0.1f;
      float yTran = 0.1f;
      @Override
      public void keyPressed(KeyEvent d) {
          loopBool = true;
          while (loopBool = true) {
              try {
                  Thread.sleep(100);
              } catch (InterruptedException e) {
                  e.printStackTrace();
              }
          }
  
      }
  
      @Override
      public void keyReleased(KeyEvent d) {
      }
  }
  </code></pre>