Class KeyEvent


  • public class KeyEvent
    extends Event
    KeyEvent is a key press event.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int ACTION_KEY_PRESS
      The event type for a focus being transfered to this control with the ENTER or ACTION keys.
      int key
      The key pressed or entered by other means (grafitti input).
      static int KEY_PRESS
      The event type for a key press event.
      int modifiers
      The state of the modifier keys when the event occured.
      static int SPECIAL_KEY_PRESS
      The event type for a device key press event.
    • Constructor Summary

      Constructors 
      Constructor Description
      KeyEvent()
      Constructs a KeyEvent, assigning the type as KEY_PRESS.
      KeyEvent​(int type, int key, int modifiers)
      Creates a new instance of KeyEvent with the specified type, key and modifiers.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean isActionKey()
      Returns true if the key press is an ACTION or ENTER one.
      boolean isDownKey()
      Returns true if the key press is any kind of the possible ones that means Down.
      boolean isNextKey()
      Returns true if the key press is any kind of the possible ones that means forward (TAB, PAGE_DOWN, DOWN, RIGHT, etc).
      boolean isPrevKey()
      Returns true if the key press is any kind of the possible ones that means previous (PAGE_UP, UP, LEFT, etc)
      boolean isUpKey()
      Returns true if the key press is any kind of the possible ones that means UP.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • KEY_PRESS

        public static final int KEY_PRESS
        The event type for a key press event. Device keys are handled in the SPECIAL_KEY_PRESS event.
        See Also:
        Constant Field Values
      • ACTION_KEY_PRESS

        public static final int ACTION_KEY_PRESS
        The event type for a focus being transfered to this control with the ENTER or ACTION keys.
        See Also:
        Constant Field Values
      • SPECIAL_KEY_PRESS

        public static final int SPECIAL_KEY_PRESS
        The event type for a device key press event. Note that some keys are posted only when they are released.
        See Also:
        Constant Field Values
      • key

        public int key
        The key pressed or entered by other means (grafitti input). This is either a normal character key (if the value is < 70000) or one of the special keys defined in the DeviceKeys interface.
        See Also:
        SpecialKeys
      • modifiers

        public int modifiers
        The state of the modifier keys when the event occured. This is a OR'ed combination of the modifiers present in the DeviceKeys interface.
        See Also:
        SpecialKeys
    • Constructor Detail

      • KeyEvent

        public KeyEvent()
        Constructs a KeyEvent, assigning the type as KEY_PRESS.
      • KeyEvent

        public KeyEvent​(int type,
                        int key,
                        int modifiers)
        Creates a new instance of KeyEvent with the specified type, key and modifiers.
        Parameters:
        type - the KeyEvent type, must be either KEY_PRESS, ACTION_KEY_PRESS or SPECIAL_KEY_PRESS
        key - the input key
        modifiers - state of the modifier keys for this event
        Throws:
        java.lang.IllegalArgumentException - if the type argument is not equal to KEY_PRESS, ACTION_KEY_PRESS or SPECIAL_KEY_PRESS.
        Since:
        TotalCross 1.33
        See Also:
        KEY_PRESS, ACTION_KEY_PRESS, SPECIAL_KEY_PRESS
    • Method Detail

      • isActionKey

        public boolean isActionKey()
        Returns true if the key press is an ACTION or ENTER one.
        Since:
        SuperWaba 5.5
      • isUpKey

        public boolean isUpKey()
        Returns true if the key press is any kind of the possible ones that means UP.
        Since:
        SuperWaba 5.5
      • isDownKey

        public boolean isDownKey()
        Returns true if the key press is any kind of the possible ones that means Down.
        Since:
        SuperWaba 5.5
      • isNextKey

        public boolean isNextKey()
        Returns true if the key press is any kind of the possible ones that means forward (TAB, PAGE_DOWN, DOWN, RIGHT, etc).
        Since:
        SuperWaba 5.5
      • isPrevKey

        public boolean isPrevKey()
        Returns true if the key press is any kind of the possible ones that means previous (PAGE_UP, UP, LEFT, etc)
        Since:
        SuperWaba 5.5
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class Event