Key.java
01 /*
02  * Key.java
03  *
04  * Copyright (c) 1998-2005, The University of Sheffield.
05  *
06  * This file is part of GATE (see http://gate.ac.uk/), and is free
07  * software, licenced under the GNU Library General Public License,
08  * Version 2, June1991.
09  *
10  * A copy of this licence is included in the distribution in the file
11  * licence.html, and is also available at http://gate.ac.uk/gate/licence.html.
12  *
13  * Valentin Tablan, October 2000
14  *
15  * $Id: Key.java 6491 2005-01-11 13:51:38Z ian $
16  */
17 
18 package guk.im;
19 import java.awt.event.KeyEvent;
20 
21 /**
22  * This calls describes a keyboard key.
23  * A key is defined by one character and modifiers (CTRL or ALT or both).
24  *
25  */
26 public class Key {
27   /**    */
28   public Key(char keyChar, int modifiers){
29     this.keyChar = keyChar;
30     this.modifiers = modifiers;
31   }
32 
33   /**    */
34   public int hashCode(){
35     return (int)keyChar;
36   }
37 
38   /**    */
39   public boolean equals(Object o){
40     if(instanceof Key){
41       Key other = (Key)o;
42       return keyChar == other.keyChar &&
43              (modifiers & KeyEvent.ALT_MASK==
44                 (other.modifiers & KeyEvent.ALT_MASK&&
45              (modifiers & KeyEvent.CTRL_MASK==
46                 (other.modifiers & KeyEvent.CTRL_MASK);
47     }else return false;
48   }
49 
50   /**    */
51   char keyChar;
52   /**    */
53   int modifiers;
54 }//class Key