View Javadoc
1   package org.newdawn.slick.command;
2   
3   /**
4    * A control relating to a command indicate that it should be fired when a specific key is pressed
5    * or released.
6    * 
7    * @author joverton
8    */
9   public class KeyControl implements Control {
10      /** The key code that needs to be pressed. */
11      private final int keycode;
12      
13      /**
14       * Create a new control that caused an command to be fired on a key pressed/released.
15       * 
16       * @param keycode The code of the key that causes the command
17       */
18      public KeyControl(int keycode) {     
19          this.keycode = keycode;
20      }
21  
22      /* (non-Javadoc)
23       * @see java.lang.Object#hashCode()
24       */
25      @Override
26      public int hashCode() {
27          final int prime = 31;
28          int result = 1;
29          result = prime * result + keycode;
30          return result;
31      }
32  
33      /* (non-Javadoc)
34       * @see java.lang.Object#equals(java.lang.Object)
35       */
36      @Override
37      public boolean equals(Object obj) {
38          if (this == obj) {
39              return true;
40          }
41          if (obj == null) {
42              return false;
43          }
44          if (!(obj instanceof KeyControl)) {
45              return false;
46          }
47          KeyControl other = (KeyControl) obj;
48          if (keycode != other.keycode) {
49              return false;
50          }
51          return true;
52      }
53  }