Class AdvancedKeyPressDetector

  • All Implemented Interfaces:
    java.awt.event.AWTEventListener, java.util.EventListener

    public class AdvancedKeyPressDetector
    extends java.lang.Object
    implements java.awt.event.AWTEventListener
    Helper object that allows cross-platform detection of key press and release events instance is available globally as Main.map.keyDetector.
    Since:
    7217
    • Method Detail

      • addModifierExListener

        public void addModifierExListener​(ModifierExListener l)
        Adds an object that wants to receive extended key modifier changed events.
        Parameters:
        l - listener to add
        Since:
        12517
      • register

        public void register()
        Register this object as AWTEventListener
      • unregister

        public void unregister()
        Unregister this object as AWTEventListener lists of listeners are not cleared!
      • processKeyEvent

        private void processKeyEvent​(java.awt.event.KeyEvent e)
      • eventDispatched

        public void eventDispatched​(java.awt.AWTEvent e)
        Specified by:
        eventDispatched in interface java.awt.event.AWTEventListener
      • isKeyPressed

        public boolean isKeyPressed​(int keyCode)
        Allows to determine if the key with specific code is pressed now
        Parameters:
        keyCode - the key code, for example KeyEvent.VK_ENTER
        Returns:
        true if the key is pressed now
      • setEnabled

        public final void setEnabled​(boolean enabled)
        Sets the enabled state of the key detector. We need to disable it when text fields that disable shortcuts gain focus.
        Parameters:
        enabled - if true, enables this key detector. If false, disables it
        Since:
        7539