Class NativeKeyboardEvent

  • All Implemented Interfaces:
    IsJSType, IsCastable

    @JsType(isNative=true,
            name="KeyboardEvent",
            namespace="<global>")
    public final class NativeKeyboardEvent
    extends NativeUIEvent
    Describes a user interaction with the keyboard; each event describes a single interaction between the user and a key (or combination of a key with modifier keys) on the keyboard.
    The event type (keydown or keyup) identifies what kind of keyboard activity occurred.
    Author:
    Andrea "Stock" Stocchero
    • Method Detail

      • getKey

        @JsProperty
        public String getKey()
        Returns the value of the key pressed by the user, taking into consideration the state of modifier keys as well as the keyboard locale and layout.
        Returns:
        the value of the key pressed by the user, taking into consideration the state of modifier keys as well as the keyboard locale and layout.
      • getCode

        @JsProperty
        public String getCode()
        Returns a physical key on the keyboard (as opposed to the character generated by pressing the key).
        In other words, this property returns a value that isn't altered by keyboard layout or the state of the modifier keys.
        Returns:
        a physical key on the keyboard (as opposed to the character generated by pressing the key)
      • isRepeat

        @JsProperty
        public boolean isRepeat()
        Returns a boolean value that is true if the given key is being held down such that it is automatically repeating.
        Returns:
        a boolean value that is true if the given key is being held down such that it is automatically repeating
      • isAltKey

        @JsProperty
        public boolean isAltKey()
        Returns true if the alt key was down when the mouse event was fired.
        Returns:
        true if the alt key was down when the mouse event was fired
      • isCtrlKey

        @JsProperty
        public boolean isCtrlKey()
        Returns true if the control key was down when the mouse event was fired.
        Returns:
        true if the control key was down when the mouse event was fired
      • isMetaKey

        @JsProperty
        public boolean isMetaKey()
        Returns true if the meta key was down when the mouse event was fired.
        Returns:
        true if the meta key was down when the mouse event was fired
      • isShiftKey

        @JsProperty
        public boolean isShiftKey()
        Returns true if the shift key was down when the mouse event was fired.
        Returns:
        true if the shift key was down when the mouse event was fired
      • createKeyboardEvent

        @JsOverlay
        public static NativeKeyboardEvent createKeyboardEvent​(String type)
        Creates a new event object for a specific event type.
        Parameters:
        type - type of event
        Returns:
        a new event object for a specific event type
      • createKeyboardEvent

        @JsOverlay
        public static NativeKeyboardEvent createKeyboardEvent​(IsEvent type)
        Creates a new event object for a specific event type.
        Parameters:
        type - type of event
        Returns:
        a new event object for a specific event type
      • createKeyboardEvent

        @JsOverlay
        public static NativeKeyboardEvent createKeyboardEvent​(IsEvent type,
                                                              KeyboardEventInit init)
        Creates a new event object for a specific event type with initial configuration.
        Parameters:
        type - type of event
        init - initial configuration of the event
        Returns:
        a new event object for a specific event type
      • createKeyboardEvent

        @JsOverlay
        public static NativeKeyboardEvent createKeyboardEvent​(String type,
                                                              KeyboardEventInit init)
        Creates a new event object for a specific event type with initial configuration.
        Parameters:
        type - type of event
        init - initial configuration of the event
        Returns:
        a new event object for a specific event type
      • getLocation

        @JsOverlay
        public KeyboardLocation getLocation()
        Returns the location of the key on the keyboard or other input device.
        Returns:
        the location of the key on the keyboard or other input device