title: KeyListener is not working
body: <p>The following code is not working.  I am trying to move a player left, right, up, and, down using key pressed method but when i press the keys it does not respond.  I did not paste the whole code just the part that moves the box there are other if statements to achieve movement of other contents.</p>
  
  <hr>
  
  <pre><code>public class innerClassKeyPressed {
  
  
     void  keyPressed( KeyEvent e)
     {
      int key= e.getKeyCode();
      if(key==KeyEvent.VK_LEFT){
          dx=-1;
      }
       if(key==KeyEvent.VK_RIGHT){
  
           dx=1;
      }
      if (key==KeyEvent.VK_UP){
          dy=-1;
      }
       if (key==KeyEvent.VK_DOWN){
          dy=1;
       }
        if (key == 82)
       {
            initLevel(currlevel);
  
       } //R
       if (key == 78)
       {
           currlevel++;
            initLevel(currlevel);
        } 
  
        if ( (key == KeyEvent.VK_LEFT ) &amp;&amp; ( key  == KeyEvent.VK_RIGHT ) &amp;&amp; 
        (key == KeyEvent.VK_UP ) &amp;&amp; ( key == KeyEvent.VK_DOWN )) { 
  
           return;
         }
  
  
          for (int row=0; row &lt; myArray.length; row++)
  
          {
              for (int column=0; column &lt; myArray[row].length; column++)
              {
                   if( myArray[row][column]==  Contents.PLAYER)                       { 
                          if (myArray[row+dy][column+dx] == Contents.BOX)
                          {
  
                              if (myArray[row+dy*2][column+dx*2] == Contents.EMPTY)
  
                               {
  
                                  myArray[row+dy][column+dx]= Contents.PLAYER; 
                                   myArray[row][column]= Contents.EMPTY;
  
                                  myArray[row+dy*2][column+dx*2]= Contents.BOX;
  </code></pre>