Package jexer

Class TKeypress


  • public class TKeypress
    extends java.lang.Object
    This class represents keystrokes.
    • Constructor Detail

      • TKeypress

        public TKeypress​(boolean isKey,
                         int fnKey,
                         int ch,
                         boolean alt,
                         boolean ctrl,
                         boolean shift)
        Public constructor makes an immutable instance.
        Parameters:
        isKey - is true, this is a function key
        fnKey - the function key code (only valid if isKey is true)
        ch - the character (only valid if fnKey is false)
        alt - if true, ALT was pressed with this keystroke
        ctrl - if true, CTRL was pressed with this keystroke
        shift - if true, SHIFT was pressed with this keystroke
    • Method Detail

      • isFnKey

        public boolean isFnKey()
        Getter for isFunctionKey.
        Returns:
        if true, ch is meaningless, use keyCode instead
      • getKeyCode

        public int getKeyCode()
        Getter for function key code.
        Returns:
        function key code int value (only valid is isKey is true)
      • isAlt

        public boolean isAlt()
        Getter for ALT.
        Returns:
        alt value
      • isCtrl

        public boolean isCtrl()
        Getter for CTRL.
        Returns:
        ctrl value
      • isShift

        public boolean isShift()
        Getter for SHIFT.
        Returns:
        shift value
      • getChar

        public int getChar()
        Getter for character.
        Returns:
        the character (only valid if isKey is false)
      • dup

        public TKeypress dup()
        Create a duplicate instance.
        Returns:
        duplicate intance
      • equals

        public boolean equals​(java.lang.Object rhs)
        Comparison check. All fields must match to return true.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        rhs - another TKeypress instance
        Returns:
        true if all fields are equal
      • equalsWithoutModifiers

        public boolean equalsWithoutModifiers​(java.lang.Object rhs)
        Comparison check, omitting the ctrl/alt/shift flags.
        Parameters:
        rhs - another TKeypress instance
        Returns:
        true if all fields (except for ctrl/alt/shift) are equal
      • hashCode

        public int hashCode()
        Hashcode uses all fields in equals().
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hash
      • toString

        public java.lang.String toString()
        Make human-readable description of this TKeypress.
        Overrides:
        toString in class java.lang.Object
        Returns:
        displayable String
      • toLowerCase

        public TKeypress toLowerCase()
        Convert a keypress to lowercase. Function keys and alt/ctrl keys are not converted.
        Returns:
        a new instance with the key converted
      • toUpperCase

        public TKeypress toUpperCase()
        Convert a keypress to uppercase. Function keys and alt/ctrl keys are not converted.
        Returns:
        a new instance with the key converted