Key.java |
1 /* 2 * Key.java 3 * 4 * Copyright (c) 1998-2005, The University of Sheffield. 5 * 6 * This file is part of GATE (see http://gate.ac.uk/), and is free 7 * software, licenced under the GNU Library General Public License, 8 * Version 2, June1991. 9 * 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,v 1.5 2005/01/11 13:51:38 ian Exp $ 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(o 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 55