Class KeyUtils


  • public class KeyUtils
    extends Object
    A helper class for key events.
    Version:
    $Revision$
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    • Constructor Summary

      Constructors 
      Constructor Description
      KeyUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean isAltDown​(int modifiersEx)
      Returns whether the ALT key is down.
      static boolean isCopy​(KeyEvent e)
      Checks whether the key event was a "copy to clipboard" combination (Ctrl+C or Ctrl+Ins).
      static boolean isCtrlDown​(int modifiersEx)
      Returns whether the CTRL key is down.
      static boolean isCut​(KeyEvent e)
      Checks whether the key event was a "cut to clipboard" combination (Ctrl+X or Shift+Delete).
      static boolean isMetaDown​(int modifiersEx)
      Returns whether the META key is down.
      static boolean isNoneDown​(int modifiersEx)
      Checks whether neither CTRL/ALT/META/SHIFT is down.
      static boolean isOnlyAltDown​(int modifiersEx)
      Checks whether only ATL is not, not CTRL/META/SHIFT.
      static boolean isOnlyCtrlDown​(int modifiersEx)
      Checks whether only CTRL is not, not ALT/META/SHIFT.
      static boolean isOnlyMetaDown​(int modifiersEx)
      Checks whether only META is not, not ALT/CTRL/SHIFT.
      static boolean isOnlyShiftDown​(int modifiersEx)
      Checks whether only SHIFT is not, not ALT/META/CTRL.
      static boolean isPaste​(KeyEvent e)
      Checks whether the key event was a "insert from clipboard" combination (Ctrl+V or Shift+Ins).
      static boolean isShiftDown​(int modifiersEx)
      Returns whether the SHIFT key is down.
    • Constructor Detail

      • KeyUtils

        public KeyUtils()
    • Method Detail

      • isCopy

        public static boolean isCopy​(KeyEvent e)
        Checks whether the key event was a "copy to clipboard" combination (Ctrl+C or Ctrl+Ins).
        Parameters:
        e - the event
        Returns:
        true if a "copy" event
      • isCut

        public static boolean isCut​(KeyEvent e)
        Checks whether the key event was a "cut to clipboard" combination (Ctrl+X or Shift+Delete).
        Parameters:
        e - the event
        Returns:
        true if a "cut" event
      • isPaste

        public static boolean isPaste​(KeyEvent e)
        Checks whether the key event was a "insert from clipboard" combination (Ctrl+V or Shift+Ins).
        Parameters:
        e - the event
        Returns:
        true if a "paste" event
      • isCtrlDown

        public static boolean isCtrlDown​(int modifiersEx)
        Returns whether the CTRL key is down.
        Parameters:
        modifiersEx - the extended modifiers bitmask
        Returns:
        true if CTRL is down
      • isAltDown

        public static boolean isAltDown​(int modifiersEx)
        Returns whether the ALT key is down.
        Parameters:
        modifiersEx - the extended modifiers bitmask
        Returns:
        true if ALT is down
      • isMetaDown

        public static boolean isMetaDown​(int modifiersEx)
        Returns whether the META key is down.
        Parameters:
        modifiersEx - the extended modifiers bitmask
        Returns:
        true if META is down
      • isShiftDown

        public static boolean isShiftDown​(int modifiersEx)
        Returns whether the SHIFT key is down.
        Parameters:
        modifiersEx - the extended modifiers bitmask
        Returns:
        true if SHIFT is down
      • isNoneDown

        public static boolean isNoneDown​(int modifiersEx)
        Checks whether neither CTRL/ALT/META/SHIFT is down.
        Parameters:
        modifiersEx - the extended modifiers bitmask
        Returns:
        true if none is down
      • isOnlyCtrlDown

        public static boolean isOnlyCtrlDown​(int modifiersEx)
        Checks whether only CTRL is not, not ALT/META/SHIFT.
        Parameters:
        modifiersEx - the extended modifiers bitmask
        Returns:
        true if only CTRL is down
      • isOnlyAltDown

        public static boolean isOnlyAltDown​(int modifiersEx)
        Checks whether only ATL is not, not CTRL/META/SHIFT.
        Parameters:
        modifiersEx - the extended modifiers bitmask
        Returns:
        true if only ALT is down
      • isOnlyShiftDown

        public static boolean isOnlyShiftDown​(int modifiersEx)
        Checks whether only SHIFT is not, not ALT/META/CTRL.
        Parameters:
        modifiersEx - the extended modifiers bitmask
        Returns:
        true if only SHIFT is down
      • isOnlyMetaDown

        public static boolean isOnlyMetaDown​(int modifiersEx)
        Checks whether only META is not, not ALT/CTRL/SHIFT.
        Parameters:
        modifiersEx - the extended modifiers bitmask
        Returns:
        true if only META is down