Class NativeKeyEvent

  • All Implemented Interfaces:
    Serializable

    public class NativeKeyEvent
    extends NativeInputEvent
    An event which indicates that a keystroke occurred at global scope.

    This low-level event is generated by the native system when a key is pressed or released independent of Java component focus. The event is passed to every NativeKeyListener object which has been registered to receive global key events using the GlobalScreen.addNativeKeyListener(NativeKeyListener) method. Each NativeKeyListener object will receive a NativeKeyEvent when the event occurs.

    All NativeKeyEvent objects are dependent on the native platform and keyboard layout. NATIVE_KEY_PRESSED and NATIVE_KEY_RELEASED events are generated for every key code received by the native system. The key being pressed or released is indicated by the getKeyCode method, which returns a virtual key code or VC_UNDEFINED. Please note that getKeyChar() for events of type NATIVE_KEY_PRESSED and NATIVE_KEY_RELEASED will always return CHAR_UNDEFINED.

    NATIVE_KEY_TYPED events are produced for NATIVE_KEY_PRESSED events that produce valid Unicode characters for the current keyboard layout. The getKeyChar() method always returns a valid Unicode character for this type of event. Please note that getKeyCode() will always return VC_UNDEFINED for NATIVE_KEY_TYPED events.

    Virtual key codes only represent the physical key that has been pressed and should not be mistaken with the character mapped to that key by the operating system. NATIVE_KEY_PRESSED and NATIVE_KEY_RELEASED events should only be used to determin phisical key state, while NATIVE_KEY_TYPED events can be used to determine the Unicode representation of the NativeKeyEvent.

    Since:
    1.0
    Version:
    2.0
    Author:
    Alexander Barker (alex@1stleg.com)
    See Also:
    GlobalScreen, NativeKeyListener, Serialized Form