- return ((isKey == that.isKey)
- && (fnKey == that.fnKey)
- && (ch == that.ch)
- && (alt == that.alt)
- && (ctrl == that.ctrl)
- && (shift == that.shift));
+ return ((isFunctionKey == that.isFunctionKey)
+ && (keyCode == that.keyCode)
+ && (ch == that.ch)
+ && (alt == that.alt)
+ && (ctrl == that.ctrl)
+ && (shift == that.shift));
+ }
+
+ /**
+ * Comparison check, omitting the ctrl/alt/shift flags.
+ *
+ * @param rhs another TKeypress instance
+ * @return true if all fields (except for ctrl/alt/shift) are equal
+ */
+ public boolean equalsWithoutModifiers(final Object rhs) {
+ if (!(rhs instanceof TKeypress)) {
+ return false;
+ }
+
+ TKeypress that = (TKeypress) rhs;
+ return ((isFunctionKey == that.isFunctionKey)
+ && (keyCode == that.keyCode)
+ && (ch == that.ch));
+ }
+
+ /**
+ * Hashcode uses all fields in equals().
+ *
+ * @return the hash
+ */
+ @Override
+ public int hashCode() {
+ int A = 13;
+ int B = 23;
+ int hash = A;
+ hash = (B * hash) + (isFunctionKey ? 1 : 0);
+ hash = (B * hash) + keyCode;
+ hash = (B * hash) + ch;
+ hash = (B * hash) + (alt ? 1 : 0);
+ hash = (B * hash) + (ctrl ? 1 : 0);
+ hash = (B * hash) + (shift ? 1 : 0);
+ return hash;