Class NativeInputEvent

java.lang.Object
java.util.EventObject
com.github.kwhat.jnativehook.NativeInputEvent
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
NativeKeyEvent, NativeMouseEvent

public class NativeInputEvent extends EventObject
The root event class for all native-level input events. Input events are delivered to listeners as they are received by the native source. There is no method for listeners or subclasses to prevent delivery of the event to the native system. There is no guarantee that the events will be received by Java before they are delivered natively.

Since:
1.0
Version:
2.1
Author:
Alexander Barker (alex@1stleg.com)
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The left alt key modifier constant.
    static final int
    Either the right or left alt key modifier constant.
    static final int
    The right alt key modifier constant.
    static final int
    The Button1 modifier constant.
    static final int
    The Button2 modifier constant.
    static final int
    The Button3 modifier constant.
    static final int
    The Button4 modifier constant.
    static final int
    The Button5 modifier constant.
    static final int
    The Caps Lock modifier constant.
    static final int
    The left ctrl key modifier constant.
    static final int
    Either the right or left ctrl key modifier constant.
    static final int
    The right ctrl key modifier constant.
    static final int
    The left meta key modifier constant.
    static final int
    Either the right or left meta key modifier constant.
    static final int
    The right meta key modifier constant.
    static final int
    The Number Lock modifier constant.
    static final int
    The Scroll Lock modifier constant.
    static final int
    The left shift key modifier constant.
    static final int
    Either the right or left shift key modifier constant.
    static final int
    The right shift key modifier constant.

    Fields inherited from class java.util.EventObject

    source
  • Constructor Summary

    Constructors
    Constructor
    Description
    NativeInputEvent(Class<GlobalScreen> source, int id, int modifiers)
    Instantiates a new native input event.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Gets the event type.
    int
    Gets the modifier flags for this event.
    static String
    getModifiersText(int modifiers)
    Gets a String describing the modifier flags, such as "Button1", or "Ctrl+Alt".
    long
    Gets the platform dependent native interval for chronological event sequencing.
    Gets a String representation of this event.
    void
    setModifiers(int modifiers)
    Deprecated. 

    Methods inherited from class java.util.EventObject

    getSource, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • SHIFT_L_MASK

      public static final int SHIFT_L_MASK
      The left shift key modifier constant.
      Since:
      2.0
      See Also:
    • CTRL_L_MASK

      public static final int CTRL_L_MASK
      The left ctrl key modifier constant.
      Since:
      2.0
      See Also:
    • META_L_MASK

      public static final int META_L_MASK
      The left meta key modifier constant.
      Since:
      2.0
      See Also:
    • ALT_L_MASK

      public static final int ALT_L_MASK
      The left alt key modifier constant.
      Since:
      2.0
      See Also:
    • SHIFT_R_MASK

      public static final int SHIFT_R_MASK
      The right shift key modifier constant.
      Since:
      2.0
      See Also:
    • CTRL_R_MASK

      public static final int CTRL_R_MASK
      The right ctrl key modifier constant.
      Since:
      2.0
      See Also:
    • META_R_MASK

      public static final int META_R_MASK
      The right meta key modifier constant.
      Since:
      2.0
      See Also:
    • ALT_R_MASK

      public static final int ALT_R_MASK
      The right alt key modifier constant.
      Since:
      2.0
      See Also:
    • SHIFT_MASK

      public static final int SHIFT_MASK
      Either the right or left shift key modifier constant.
      See Also:
    • CTRL_MASK

      public static final int CTRL_MASK
      Either the right or left ctrl key modifier constant.
      See Also:
    • META_MASK

      public static final int META_MASK
      Either the right or left meta key modifier constant.
      See Also:
    • ALT_MASK

      public static final int ALT_MASK
      Either the right or left alt key modifier constant.
      See Also:
    • BUTTON1_MASK

      public static final int BUTTON1_MASK
      The Button1 modifier constant.
      See Also:
    • BUTTON2_MASK

      public static final int BUTTON2_MASK
      The Button2 modifier constant.
      See Also:
    • BUTTON3_MASK

      public static final int BUTTON3_MASK
      The Button3 modifier constant.
      See Also:
    • BUTTON4_MASK

      public static final int BUTTON4_MASK
      The Button4 modifier constant.
      See Also:
    • BUTTON5_MASK

      public static final int BUTTON5_MASK
      The Button5 modifier constant.
      See Also:
    • NUM_LOCK_MASK

      public static final int NUM_LOCK_MASK
      The Number Lock modifier constant.
      See Also:
    • CAPS_LOCK_MASK

      public static final int CAPS_LOCK_MASK
      The Caps Lock modifier constant.
      See Also:
    • SCROLL_LOCK_MASK

      public static final int SCROLL_LOCK_MASK
      The Scroll Lock modifier constant.
      See Also:
  • Constructor Details

    • NativeInputEvent

      public NativeInputEvent(Class<GlobalScreen> source, int id, int modifiers)
      Instantiates a new native input event.
      Parameters:
      source - The source of the event.
      id - The type of event.
      modifiers - the modifier keys down during event. NativeInputEvent _MASK modifiers should be used as they are not compatible with the extended _DOWN_MASK or the old _MASK InputEvent modifiers.
  • Method Details

    • getID

      public int getID()
      Gets the event type.
      Returns:
      the event type
    • getWhen

      public long getWhen()
      Gets the platform dependent native interval for chronological event sequencing.
      Returns:
      the native timestamp
    • getModifiers

      public int getModifiers()
      Gets the modifier flags for this event.
      Returns:
      the modifier flags
    • setModifiers

      public void setModifiers(int modifiers)
      Deprecated.
      Sets the modifier flags for this event.
      Parameters:
      modifiers - the new modifier flags
    • getModifiersText

      public static String getModifiersText(int modifiers)
      Gets a String describing the modifier flags, such as "Button1", or "Ctrl+Alt". These strings can be localized by changing the awt.properties file.
      Parameters:
      modifiers - a modifier mask describing the modifier keys and mouse buttons of an event.
      Returns:
      the modifier mask's textual representation.
    • paramString

      public String paramString()
      Gets a String representation of this event. This method is useful for event-logging and debugging.
      Returns:
      a string identifying the event and its attributes