Advertisement
G-Rath

KeyManager

Mar 14th, 2014
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.01 KB | None | 0 0
  1. import java.awt.event.KeyEvent;
  2. import java.awt.event.*; //KeyListener
  3.  
  4. public class KeyManager implements KeyListener
  5. {
  6.  
  7.     private Skeleton gameSk;
  8.  
  9.     /**
  10.      * Constructor for objects of class KeyManager
  11.      */
  12.     public KeyManager( Skeleton sk )
  13.     {
  14.         // initialise instance variables
  15.         gameSk = sk;
  16.     }
  17.  
  18.     /** Handle the key typed event from the text field. */
  19.     public void keyTyped(KeyEvent e)
  20.     {
  21.         //System.out.println( "Key typed: " + e.getKeyChar() );
  22.     }
  23.  
  24.     /** Handle the key-pressed event from the text field. */
  25.     public void keyPressed(KeyEvent e)
  26.     {
  27.         if( gameSk != null )
  28.             gameSk.keyPressed( e );
  29.         //System.out.println( "Key pressed: " + e.getKeyChar() );
  30.     }
  31.  
  32.     /** Handle the key-released event from the text field. */
  33.     public void keyReleased(KeyEvent e)
  34.     {
  35.         if( gameSk != null )
  36.             gameSk.keyReleased( e );
  37.         //System.out.println( "Key released: " + e.getKeyChar() );
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement